Azure / Azure/azure-powershell
Get-AzPolicyAssignment has problems with policy name containing an ampersand &
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Description
We have a customer that has subscriptions containing a `&`.
We construct a policy assignment name with `tag` - `subscriptionname`
So for example `Critical - Hewlett & Packard - Development`
If I want to check if a policy assignment with that name already exists, I would simply use `Get-AzPolicyAssignment` to check if the assignment exists or not.
Unfortunately the cmdlet doesn't seem to like `&` signs and throws up code:
```powershell
Get-AzPolicyAssignment -Name 'Critical - Hewlett & Packard - Development' -Scope '/subscriptions/00000000-0000-0000-0000-000000000' -ErrorAction Stop
Get-AzPolicyAssignment_Get: C:\bgates\PowerShell\Modules\Az.Resources\7.4.0\Policy.Autorest\custom\Get-AzPolicyAssignment.ps1:250:19
Line |
250 | $scriptCmd = {& $wrappedCmd @calledParameters}
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Expected literal (number, boolean, or null). Was '<'.
```
Have tried this on various versions of the module, but problem still exists.
Ran this on my colleagues machine, but also in a 7.2 clean Automation Account using 'default' latest version of the modules.
When trying the same thing manually, using the exact same name in the Portal, it does work just fine, both getting the info and creating/editing a policy assignment.
### Issue script & Debug output
```PowerShell
$DebugPreference='Continue'
Get-AzPolicyAssignment -Name 'Critical - Hewlett & Packard - Development' -Scope '/subscriptions/00000000-0000-0000-0000-000000000' -ErrorAction Stop
DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: //subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.Authorization/policyAssignments/Critical-%20-%20Hewlett%20%26%20Packard?api-version=2023-04-01
DEBUG: RequestCreated: //subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.Authorization/policyAssignments/Critical%20-%20Hewlett%20%26%20Packard?api-version=2023-04-01
DEBUG: HeaderParametersAdded:
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com//subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.Authorization/policyAssignments/Critical - Hewlett %26 Packard?api-version=2023-04-01
Headers:
x-ms-unique-id : 2
x-ms-client-request-id : 6e92565f-67a7-4259-abf8-cccef5f9cef0
CommandName : &
FullCommandName : Get-AzPolicyAssignment_Get
ParameterSetName : __AllParameterSets
User-Agent : AzurePowershell/v12.1.0,PSVersion/v7.4.6,Az.Policy/7.4.0
Body:
DEBUG: BeforeCall:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
BadRequest
Headers:
Cache-Control : private
X-Cache : CONFIG_NOCACHE
X-MSEdge-Ref : Ref A: 381A61676B6440559FE2E19D4C681346 Ref B: AMS231032608035 Ref C: 2024-11-29T13:45:50Z
Date : Fri, 29 Nov 2024 13:45:49 GMT
Body:
Runtime Error
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:pointer; }
@media screen and (max-width: 639px) {
pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
}
@media screen and (max-width: 479px) {
pre { width: 280px; }
}
Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
DEBUG: [Finally]: Cannot deserialize due to Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
DEBUG: [Finally]: Getting exception 'Microsoft.Azure.Commands.Common.Exceptions.AzPSCloudException: InternalException' from response
DEBUG: Finally:
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: [CmdletException]: Received Exception with message 'ParserException - Expected literal (number, boolean, or null). Was '<'. : at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonTokenizer.ReadIdentifer()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonTokenizer.ReadLiteral()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonTokenizer.ReadNext()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.TokenReader.Next()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonParser..ctor(SourceReader sourceReader)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonNode.Parse(SourceReader sourceReader)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonNode.Parse(String text)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.<>c.b__44_1(Task`1 body)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Cmdlets.GetAzPolicyAssignment_Get.onDefault(HttpResponseMessage responseMessage, Task`1 response)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.PolicyAssignmentsGet_Call(HttpRequestMessage request, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.PolicyAssignmentsGet_Call(HttpRequestMessage request, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.PolicyAssignmentsGet(String scope, String policyAssignmentName, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Cmdlets.GetAzPolicyAssignment_Get.ProcessRecordAsync()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Cmdlets.GetAzPolicyAssignment_Get.ProcessRecordAsync()'
DEBUG: CmdletException: ParserException - Expected literal (number, boolean, or null). Was '<'. : at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonTokenizer.ReadIdentifer()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonTokenizer.ReadLiteral()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonTokenizer.ReadNext()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.TokenReader.Next()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonParser..ctor(SourceReader sourceReader)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonNode.Parse(SourceReader sourceReader)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonNode.Parse(String text)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.<>c.b__44_1(Task`1 body)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Cmdlets.GetAzPolicyAssignment_Get.onDefault(HttpResponseMessage responseMessage, Task`1 response)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.PolicyAssignmentsGet_Call(HttpRequestMessage request, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.PolicyAssignmentsGet_Call(HttpRequestMessage request, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.PolicyAssignmentsGet(String scope, String policyAssignmentName, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Cmdlets.GetAzPolicyAssignment_Get.ProcessRecordAsync()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Cmdlets.GetAzPolicyAssignment_Get.ProcessRecordAsync()
DEBUG: CmdletProcessRecordEnd:
Get-AzPolicyAssignment_Get: C:\bgates\PowerShell\Modules\Az.Resources\7.4.0\Policy.Autorest\custom\Get-AzPolicyAssignment.ps1:250:19
Line |
250 | $scriptCmd = {& $wrappedCmd @calledParameters}
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Expected literal (number, boolean, or null). Was '<'.
DEBUG: Setting WindowTitle: My Terminal [main] - PowerShell 7.4 (42880)
```
### Environment data
```PowerShell
$PSVersionTable
Name Value
---- -----
PSVersion 7.4.6
PSEdition Core
GitCommitId 7.4.6
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
### Module versions
```PowerShell
get-module az*
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 3.0.4 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script 7.4.0 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…}
```
### Error output
```PowerShell
Resolve-AzError
DEBUG: 14:46:00 - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 14:46:00 - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 14:46:00 - using account id 'adm_Gijs.vanSoest@topigsnorsvin.onmicrosoft.com'...
DEBUG: 14:46:00 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 14:46:00 - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
HistoryId: 32
Message : Expected literal (number, boolean, or null). Was '<'.
StackTrace : at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonTokenizer.ReadIdentifer()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonTokenizer.ReadLiteral()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonTokenizer.ReadNext()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.TokenReader.Next()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonParser..ctor(SourceReader sourceReader)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonNode.Parse(SourceReader sourceReader)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonNode.Parse(String text)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.<>c.b__44_1(Task`1 body)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Cmdlets.GetAzPolicyAssignment_Get.onDefault(HttpResponseMessage responseMessage, Task`1 response)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.PolicyAssignmentsGet_Call(HttpRequestMessage request, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.PolicyAssignmentsGet_Call(HttpRequestMessage request, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.PolicyAssignmentsGet(String scope, String policyAssignmentName, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Cmdlets.GetAzPolicyAssignment_Get.ProcessRecordAsync()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Cmdlets.GetAzPolicyAssignment_Get.ProcessRecordAsync()
Exception : Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.ParserException
InvocationInfo : {Get-AzPolicyAssignment_Get}
Line : $scriptCmd = {& $wrappedCmd @calledParameters}
Position : At C:\bgates\PowerShell\Modules\Az.Resources\7.4.0\Policy.Autorest\custom\Get-AzPolicyAssignment.ps1:250 char:19
+ $scriptCmd = {& $wrappedCmd @calledParameters}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 32
DEBUG: 14:46:01 - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
HistoryId: 30
Message : Cannot validate argument on parameter 'Uri'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
StackTrace : 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)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception : System.Management.Automation.ParameterBindingValidationException
InvocationInfo : {Invoke-RestMethod}
Line : $groups = Invoke-RestMethod -Method Get -Uri $groupUrl -Headers $authToken
Position : At line:1 char:46
+ $groups = Invoke-RestMethod -Method Get -Uri $groupUrl -Headers $auth …
+ ~~~~~~~~~
HistoryId : 30
DEBUG: 14:46:01 - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
Message : The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
StackTrace : at System.Management.Automation.ValidateNotNullOrAttributeBase.Validate(Object arguments, EngineIntrinsics engineIntrinsics)
at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
Exception : System.Management.Automation.ValidationMetadataException
InvocationInfo : {Invoke-RestMethod}
Line : $groups = Invoke-RestMethod -Method Get -Uri $groupUrl -Headers $authToken
Position : At line:1 char:46
+ $groups = Invoke-RestMethod -Method Get -Uri $groupUrl -Headers $auth …
+ ~~~~~~~~~
HistoryId : 30
DEBUG: 14:46:01 - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
HistoryId: 29
Message : Expected literal (number, boolean, or null). Was '<'.
StackTrace : at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonTokenizer.ReadIdentifer()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonTokenizer.ReadLiteral()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonTokenizer.ReadNext()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.TokenReader.Next()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonParser..ctor(SourceReader sourceReader)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonNode.Parse(SourceReader sourceReader)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.JsonNode.Parse(String text)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.<>c.b__44_1(Task`1 body)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Cmdlets.GetAzPolicyAssignment_Get.onDefault(HttpResponseMessage responseMessage, Task`1 response)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.PolicyAssignmentsGet_Call(HttpRequestMessage request, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.PolicyAssignmentsGet_Call(HttpRequestMessage request, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Policy.PolicyAssignmentsGet(String scope, String policyAssignmentName, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Cmdlets.GetAzPolicyAssignment_Get.ProcessRecordAsync()
at Microsoft.Azure.PowerShell.Cmdlets.Policy.Cmdlets.GetAzPolicyAssignment_Get.ProcessRecordAsync()
Exception : Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Json.ParserException
InvocationInfo : {Get-AzPolicyAssignment_Get}
Line : $scriptCmd = {& $wrappedCmd @calledParameters}
Position : At C:\bgates\PowerShell\Modules\Az.Resources\7.4.0\Policy.Autorest\custom\Get-AzPolicyAssignment.ps1:250 char:19
+ $scriptCmd = {& $wrappedCmd @calledParameters}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 29
DEBUG: 14:46:01 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 14:46:01 - [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.6; IsSuccess: True; Duration: 00:00:00.1822805; SanitizeDuration: 00:00:00.0148568
DEBUG: 14:46:01 - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 14:46:01 - ResolveError end processing.
DEBUG: Setting WindowTitle: My Terminal [main] - PowerShell 7.4 (42880)
```
Contributor guide
Research direction
Start by reproducing the command in the issue and inspect Policy.Autorest/custom/Get-AzPolicyAssignment.ps1 around line 250, along with the debug URL and response. Done means Get-AzPolicyAssignment can retrieve the assignment when its name contains an ampersand without the parser error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100