You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Get-AzPolicyState returns Object reference not set to an instance of an object. This only happens with the latest version of Powershell 6. Worked fine with PSVersion 6.1.2
Steps to reproduce
Install latest Powershell 6 and latest Az-module. Set your Az context and then run command "Get-AzPolicystate"
Environment data
Name Value
---- -----
PSVersion 6.2.1
PSEdition Core
GitCommitId 6.2.1
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
DEBUG: AzureQoSEvent: CommandName - Get-AzPolicyState; IsSuccess - False; Duration - 00:00:04.8622169; Exception - System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Azure.Commands.PolicyInsights.Models.PolicyState..ctor(PolicyState policyState)
at Microsoft.Azure.Commands.PolicyInsights.Cmdlets.GetAzureRmPolicyState.<>c.<ExecuteCmdlet>b__64_0(PolicyState policyState)
at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
at System.Management.Automation.MshCommandRuntime._WriteObjectsSkipAllowCheck(Object sendToPipeline)
at System.Management.Automation.Cmdlet.WriteObject(Object sendToPipeline, Boolean enumerateCollection)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.WriteObject(Object sendToPipeline, Boolean enumerateCollection)
at Microsoft.Azure.Commands.PolicyInsights.Cmdlets.GetAzureRmPolicyState.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
Error output
Message : Object reference not set to an instance of an object.
StackTrace : at Microsoft.Azure.Commands.PolicyInsights.Models.PolicyState..ctor(PolicyState policyState)
at Microsoft.Azure.Commands.PolicyInsights.Cmdlets.GetAzureRmPolicyState.<>c.<ExecuteCmdlet>b__64_0(PolicyState policyState)
at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
at System.Management.Automation.MshCommandRuntime._WriteObjectsSkipAllowCheck(Object sendToPipeline)
at System.Management.Automation.Cmdlet.WriteObject(Object sendToPipeline, Boolean enumerateCollection)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.WriteObject(Object sendToPipeline, Boolean enumerateCollection)
at Microsoft.Azure.Commands.PolicyInsights.Cmdlets.GetAzureRmPolicyState.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : System.NullReferenceException
InvocationInfo : {Get-AzPolicyState}
Line : Get-AzPolicyState
Position : At line:1 char:1
+ Get-AzPolicyState
+ ~~~~~~~~~~~~~~~~~
The text was updated successfully, but these errors were encountered:
@mikkokok Hey Mikko, thanks for reporting this -- it looks like this is a similar to issue to this bug that was patched last release, but is occurring in other types inside of PolicyInsights. We'll fix this in PolicyState and see if there are any other types that could hit this issue.
Description
Get-AzPolicyState returns Object reference not set to an instance of an object. This only happens with the latest version of Powershell 6. Worked fine with PSVersion 6.1.2
Steps to reproduce
Environment data
Module versions
Debug output
Error output
The text was updated successfully, but these errors were encountered: