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 | ? {$_.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, however, I believe that the intention shown by most other Powershell cmdlets is that there should be a consistent capability to pipe one command to another, especially when they are within the same module.

To workaround, I assumed the following would then work:
Get-MgApplication | ? {$_.displayname -eq 'test'} | % {Remove-MgApplication -ApplicationId $_.AppId}
This is incorrect as I need to send $_.Id because the API expects ObjectID (as per #1715 which was closed stating 'by design')

I understand that the API expects ObjectId, so why do these two applications have their parameter name as ApplicationId rather than ObjectId? Also, to assist in piping the commands together, could Remove-MgApplication have an alias for ApplicationId(aka ObjectId) that accepts InputObject.Id?

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 | ? {$_.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 | ? {$_.displayname -eq 'test'} | % {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