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

Issue in Remove-AzPolicyExemption, Update-AzPolicyExemption examples #26902

Open
ikanni opened this issue Dec 18, 2024 · 2 comments
Open

Issue in Remove-AzPolicyExemption, Update-AzPolicyExemption examples #26902

ikanni opened this issue Dec 18, 2024 · 2 comments
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Doc - Reference Policy Azure Resource Policy Service Attention This issue is responsible by Azure service team.

Comments

@ikanni
Copy link

ikanni commented Dec 18, 2024

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 ikanni added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Dec 18, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Dec 18, 2024
@isra-fel isra-fel added Doc - Reference Policy Azure Resource Policy Service Attention This issue is responsible by Azure service team. labels Dec 19, 2024
Copy link
Contributor

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

1 similar comment
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Doc - Reference Policy Azure Resource Policy Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

2 participants