Get-MgApplication & Remove-MgApplication inconsistent use of ApplicationId (unable to pipe get to remove) #3069
Labels
status:waiting-for-triage
An issue that is yet to be reviewed or assigned
type:bug
A broken experience
Describe the bug
The following code does not work:
Get-MgApplication | Where-Object {$_.displayname -eq 'test'} | Remove-MgApplication
The response from Remove-MgApplication is InputObject has null value for InputObject.ApplicationId.
This response is valid as the output from Get-MgApplication returns Id and AppId rather than ObjectId and ApplicationId.
I believe that the intention shown by previously existing Powershell cmdlets is that there should be a consistent capability to pipe one command to another, especially when they are within the same module/family, so that we do not have to encounter errors and then have to dig around the incomplete documentation to discover the quirks of newer cmdlets that run contrary to the behaviours that have been long established.
To workaround, I assumed the following would then work:
Get-MgApplication | Where-Object {$_.displayname -eq 'test'} | Foreach-Object {Remove-MgApplication -ApplicationId $_.AppId}
Unfortunately, this is also incorrect as I need to send $_.Id (because the API expects ObjectID as per #1715 which was closed stating 'by design')
I can accept that the cmdlet expects ObjectId because of upstream API requirement, so why do these two cmdlets have their parameter misleadingly named as 'ApplicationId' rather than the more correct 'ObjectId'? Also, to assist in piping the commands together, could Remove-MgApplication have an alias for ApplicationId(aka ObjectId) that accepts InputObject.Id so that it matches the naming that these cmdlets themselves output?
Finally, can the documentation of the cmdlets be updated so as to remove ambiguity around the usage of Id, ObjectId, ApplicationId and AppId?
Thanks.
Expected behavior
Should be able to pipe output from Get-MgApplication to Remove-MgApplication
How to reproduce
Create an application called 'test'
Run connect-MgGraph
Run
Get-MgApplication | Where-Object {$_.displayname -eq 'test'} | Remove-MgApplication
SDK Version
2.25.0
Latest version known to work for scenario above?
No response
Known Workarounds
Run
Get-MgApplication | Where-Object {$_.displayname -eq 'test'} | Foreach-Object {Remove-MgApplication -ApplicationId $_.Id}
Debug output
Click to expand log
```The text was updated successfully, but these errors were encountered: