microsoftgraph / microsoftgraph/msgraph-sdk-powershell
Microsoft.Graph AAD and ConfirmImpact
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 898
- Forks
- 230
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 31
Description
Various commands, such as Remove-MgUser, do not flag the impact of the change as HIGH and therefore do not invoke the confirmation dialog.
For example, running Remove-MgUser -UserId <objectId> does not request the user confirm the change. I haven't done an exhaustive look at all cmdlets but this seems to be quite prevalent throughout the Microsoft.Graph identity related cmdlets. The default $confirmPreference in Powershell is HIGH (both 5.x and 7.x). Remove actions should be considered HIGH by default.
Looking at all the modules I could see, it looks like Microsoft has set the confirm impact as medium for all Remove cmdlets. Given that the Remove verb is meant to delete objects, this could be extremely dangerous and lead to accidental deletions. You could see this (at least with all the modules I'm using) like this:
PS C:\Temp> $impact = [regex]::new("ConfirmImpact='(?<ConfirmImpact>\S+)'")
PS C:\Temp> Get-Command -module Microsoft.Graph.* -Verb Remove | foreach { $commandRef = [PSCustomObject]@{Name = $_.Name; Source = $_.Source; ConfirmImpact = $Impact.Match($_.Definition).Groups['ConfirmImpact'].Value}; $commandRef } | group -Property ConfirmImpact,Source | ft Name,Count -AutoSize
Name Count
---- -----
Medium, Microsoft.Graph.Applications 21
Medium, Microsoft.Graph.DirectoryObjects 1
Medium, Microsoft.Graph.Groups 30
Medium, Microsoft.Graph.Identity.DirectoryManagement 25
Medium, Microsoft.Graph.Identity.Governance 37
Medium, Microsoft.Graph.Identity.SignIns 59
Medium, Microsoft.Graph.Reports 1
Medium, Microsoft.Graph.Users 15
Is this by design? It's been a long standing best practice that remove actions should be set to HIGH to prevent accidental deletions (or minimize them). All the modules above are v1.21.0.
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Remove-MgUser entry point and the other Remove cmdlets in the Microsoft.Graph modules, checking their ConfirmImpact metadata and the PowerShell confirmation behavior described in the issue. Done means applicable Remove commands request confirmation at the default HIGH preference, with coverage across the affected identity-related modules.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- api, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100