Get-AzureAccount Parameters vs. Properties consistency
Get-AzureAccount cmdlet returns a property Id which has the name of the account "[email protected]". However, Get-AzureAccount has -Name parameter used to retrieve the account "[email protected]" which is totally confusing and inconsistent. The same parameter -Name with Remove-AzureAccount which trigger an error when to pipe Get-AzureAccount to Remove-AzureAccount
What I suggest here is to either change the property name returned from Get-AzureAccount from Id to Name, or change the Parameter -Name to -Id
I think what might be an appropriate solution would be:
- Add a new parameter set called something like
PipelineInputthat has a parameter called-InputObjectto theRemove-AzureAccountcommand - Strongly type the
-InputObjectparameter as aMicrosoft.Azure.Common.Extensions.Models.PSAzureAccount - Ensure that the
-InputObjectparameter hasValueFromPipelineset toTrue - Inside the cmdlet / function body, under the
PROCESSblock, if the parameter set name isPipelineInput, then remove the account with theIdproperty on each object that was piped in.
This way, when a PSAzureAccount object is piped into the Remove-AzureAccount command, the account will be removed with the correct property. Users should not have to specify that the Id property of the PSAzureAccount object maps to the -Name parameter of the Remove-AzureAccount command.
Cheers, Trevor Sullivan Microsoft MVP: PowerShell http://trevorsullivan.net http://twitter.com/pcgeek86
@SherifTalaat We didn't see any scenarios for piping accounts between the cmdlets, which is why there is this mismatch. Meanwhile Get-AzureSubscription | Remove-AzureSubscription is the right way to do this - subscription is still the primary key into the profile.
Meanwhile we will consider allowing piping for a future release