azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Issue in Remove-AzPolicyExemption, Update-AzPolicyExemption examples

Open ikanni opened this issue 1 year ago • 4 comments

Description

Issue in Remove-AzPolicyExemption, Update-AzPolicyExemption examples.

$PolicyExemption.ResourceId mentioned in examples is wrong and it should be $PolicyExemption.Id

Image

Issue script & Debug output

PS /home/ilavelan> Remove-AzPolicyExemption -Id $PolicyExemption.ResourceId -Force                 
Remove-AzPolicyExemption: Cannot bind argument to parameter 'Id' because it is an empty string.

Environment data

PS /home/ilavelan> $PSVersionTable                                                          

Name                           Value
----                           -----
PSVersion                      7.4.5
PSEdition                      Core
GitCommitId                    7.4.5
OS                             CBL-Mariner/Linux
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

PS /home/ilavelan> Get-Module Az*

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     3.0.4                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script     8.4.0                 Az.Compute                          {Add-AzImageDataDisk, Add-AzVhd, Add-AzVMAdditionalUnattendContent, Add-AzVMDataDisk…}
Script     7.9.0                 Az.Network                          {Add-AzApplicationGatewayAuthenticationCertificate, Add-AzApplicationGatewayBackendAddressPool, Add-AzApplicationGatewayBackendHttpSetting, Add-AzApplicationGatewayBackendSetting…}
Script     7.5.0                 Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…}
Script     7.4.0                 Az.Storage                          {Add-AzRmStorageContainerLegalHold, Add-AzStorageAccountManagementPolicyAction, Add-AzStorageAccountNetworkRule, Close-AzStorageFileHandle…}
Script     1.1.3                 Az.Tools.Predictor                  {Disable-AzPredictor, Enable-AzPredictor, Open-AzPredictorSurvey, Send-AzPredictorRating}
Script     0.0.0.10              AzureAD.Standard.Preview            {Add-AzureADApplicationOwner, Add-AzureADDeviceRegisteredOwner, Add-AzureADDeviceRegisteredUser, Add-AzureADDirectoryRoleMember…}
Script     0.9.3                 AzurePSDrive

Error output

PS /home/ilavelan> Resolve-AzError
DEBUG: 8:04:18 PM - [ConfigManager] Got [True] from [DisplaySecretsWarning], Module = [], Cmdlet = [].
DEBUG: 8:04:18 PM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 8:04:18 PM - using account id 'MSI@50342'...
DEBUG: 8:04:18 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 8:04:18 PM - [ConfigManager] Got [True] from [DisplaySecretsWarning], Module = [], Cmdlet = [].

   HistoryId: 37

Message        : Cannot bind argument to parameter 'Id' because it is an empty string.
StackTrace     :    at System.Management.Automation.ParameterBinderBase.ValidateNullOrEmptyArgument(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, Type argumentType, Object parameterValue, Boolean recurseIntoCollections)
                    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindNamedParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter)
                    at System.Management.Automation.ParameterBinderController.BindNamedParameters(UInt32 parameterSets, Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
                    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
                    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                 --- End of stack trace from previous location ---
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.ParameterBindingValidationException
InvocationInfo : {Remove-AzPolicyExemption}
Line           : Remove-AzPolicyExemption -Id $PolicyExemption.ResourceId -Force 
Position       : At line:1 char:30
                 + Remove-AzPolicyExemption -Id $PolicyExemption.ResourceId -Force
                 +                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 37

DEBUG: 8:04:18 PM - [ConfigManager] Got [True] from [DisplaySecretsWarning], Module = [], Cmdlet = [].

   HistoryId: 31

Message        : [PolicyEvaluationFailure] : The request failed with status code 'InternalServerError'. Details: Encountered internal server error. Diagnostic information: timestamp '20241218T200108Z', subscription id 'cbbe1416-8eb0-425f-a31c-634fcd9987f4', tracking id 
                 '56898915-cdb0-4b5c-acc0-046b65a5f4f5', request correlation id 'eb251b0c-38df-44d5-ab91-2f66ff8ffe47'. Code:'InternalServerError'
StackTrace     : 
Exception      : System.Exception
InvocationInfo : {Remove-AzPolicyExemption_Delete}
Line           :         $scriptCmd = {& $wrappedCmd @PSBoundParameters}
                 
Position       : At /usr/local/share/powershell/Modules/Az.Resources/7.5.0/Policy.Autorest/custom/Remove-AzPolicyExemption.ps1:210 char:23
                 +         $scriptCmd = {& $wrappedCmd @PSBoundParameters}
                 +                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 31

DEBUG: 8:04:18 PM - [ConfigManager] Got [True] from [DisplaySecretsWarning], Module = [], Cmdlet = [].

   HistoryId: 30

Message        : A positional parameter cannot be found that accepts argument 'True'.
StackTrace     :    at System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed(ParameterBindingException originalBindingException)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
                    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
                    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                 --- End of stack trace from previous location ---
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.ParameterBindingException
InvocationInfo : {Remove-AzPolicyExemption}
Line           : Remove-AzPolicyExemption -Id $PolicyExemption.Id -Force -BackwardCompatible True
Position       : At line:1 char:1
                 + Remove-AzPolicyExemption -Id $PolicyExemption.Id -Force -BackwardComp …
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 30

DEBUG: 8:04:18 PM - [ConfigManager] Got [True] from [DisplaySecretsWarning], Module = [], Cmdlet = [].

   HistoryId: 29

Message        : Cannot bind argument to parameter 'Id' because it is an empty string.
StackTrace     :    at System.Management.Automation.ParameterBinderBase.ValidateNullOrEmptyArgument(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, Type argumentType, Object parameterValue, Boolean recurseIntoCollections)
                    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
                    at System.Management.Automation.CmdletParameterBinderController.BindNamedParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter)
                    at System.Management.Automation.ParameterBinderController.BindNamedParameters(UInt32 parameterSets, Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
                    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
                    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                 --- End of stack trace from previous location ---
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.ParameterBindingValidationException
InvocationInfo : {Remove-AzPolicyExemption}
Line           : Remove-AzPolicyExemption -Id $PolicyExemption.ResourceId -Force 
Position       : At line:1 char:30
                 + Remove-AzPolicyExemption -Id $PolicyExemption.ResourceId -Force
                 +                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 29

DEBUG: 8:04:18 PM - [ConfigManager] Got [True] from [DisplaySecretsWarning], Module = [], Cmdlet = [].

   HistoryId: 20

Message        : [InvalidRequestContent] : The request content was invalid and could not be deserialized: ''name' is not a valid selector kind. Supported selector kinds are 'resourceType, resourceLocation, resourceWithoutLocation, definitionVersion, 
                 policyDefinitionReferenceId, userPrincipalId, groupPrincipalId'.'.
StackTrace     : 
Exception      : System.Exception
InvocationInfo : {New-AzPolicyExemption_CreateExpanded}
Line           :     $scriptCmd = {& $wrappedCmd @calledParameters}
                 
Position       : At /usr/local/share/powershell/Modules/Az.Resources/7.5.0/Policy.Autorest/custom/New-AzPolicyExemption.ps1:238 char:19
                 +     $scriptCmd = {& $wrappedCmd @calledParameters}
                 +                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 20



DEBUG: 8:04:18 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 8:04:18 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent:  Module: Az.Accounts:3.0.4; CommandName: Resolve-AzError; PSVersion: 7.4.5; IsSuccess: True; Duration: 00:00:00.0077833; SanitizeDuration: 00:00:00.0004447
DEBUG: 8:04:18 PM - [ConfigManager] Got [True] from [EnableDataCollection], Module = [], Cmdlet = [].
DEBUG: 8:04:18 PM - ResolveError end processing.
PS /home/ilavelan>

ikanni avatar Dec 18 '24 20:12 ikanni

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @aperezcloud, @kenieva.

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @aperezcloud, @kenieva.

Pull Request 26999 - https://github.com/Azure/azure-powershell/pull/26999

divyeshg94 avatar Jan 11 '25 18:01 divyeshg94

Refer to https://github.com/Azure/azure-powershell/pull/27040 and https://github.com/Azure/azure-powershell/pull/27044 .

YanaXu avatar Jan 24 '25 07:01 YanaXu