Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-MgApplication & Remove-MgApplication inconsistent use of ApplicationId (unable to pipe get to remove) #3069

Open
trevor-harte-ase opened this issue Jan 10, 2025 · 0 comments
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience

Comments

@trevor-harte-ase
Copy link

trevor-harte-ase commented Jan 10, 2025

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 ```
</details>


### Configuration

Name                           Value
----                           -----
PSVersion                      7.4.5
PSEdition                      Core
GitCommitId                    7.4.5
OS                             Debian GNU/Linux 12 (bookworm)
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

X64 architecture
devcontainer based on mcr.microsoft.com/dotnet/sdk:8.0

not specific to this configuration

### Other information

_No response_
@trevor-harte-ase trevor-harte-ase added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

1 participant