-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Description
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
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
Module versions
ModuleType Version Name PSEdition ExportedCommands
---------- ------- ---- --------- ----------------
Script 2.2.0 Az Core,Desk
Script 1.3.0 Az Core,Desk
Script 1.5.2 Az.Accounts Core,Desk {Disable-AzDataCollection, Disable-AzContextAutosa…
Script 1.3.0 Az.Accounts Core,Desk {Disable-AzDataCollection, Disable-AzContextAutosa…
Script 1.0.1 Az.Aks Core,Desk {Get-AzAks, New-AzAks, Remove-AzAks, Import-AzAksC…
Script 1.1.0 Az.AnalysisServices Core,Desk {Resume-AzAnalysisServicesServer, Suspend-AzAnalys…
Script 1.0.0 Az.AnalysisServices Core,Desk {Resume-AzAnalysisServicesServer, Suspend-AzAnalys…
Script 1.1.0 Az.ApiManagement Core,Desk {Add-AzApiManagementApiToProduct, Add-AzApiManagem…
Script 1.0.0 Az.ApiManagement Core,Desk {Add-AzApiManagementRegion, Get-AzApiManagementSso…
Script 1.0.0 Az.ApplicationInsights Core,Desk {Get-AzApplicationInsights, New-AzApplicationInsig…
Script 1.2.2 Az.Automation Core,Desk {Get-AzAutomationHybridWorkerGroup, Remove-AzAutom…
Script 1.1.0 Az.Automation Core,Desk {Get-AzAutomationHybridWorkerGroup, Remove-AzAutom…
Script 1.1.0 Az.Batch Core,Desk {Remove-AzBatchAccount, Get-AzBatchAccount, Get-Az…
Script 1.0.0 Az.Batch Core,Desk {Remove-AzBatchAccount, Get-AzBatchAccount, Get-Az…
Script 1.0.0 Az.Billing Core,Desk {Get-AzBillingInvoice, Get-AzBillingPeriod, Get-Az…
Script 1.3.0 Az.Cdn Core,Desk {Get-AzCdnProfile, Get-AzCdnProfileSsoUrl, New-AzC…
Script 1.0.1 Az.Cdn Core,Desk {Get-AzCdnProfile, Get-AzCdnProfileSsoUrl, New-AzC…
Script 1.1.1 Az.CognitiveServices Core,Desk {Get-AzCognitiveServicesAccount, Get-AzCognitiveSe…
Script 1.0.0 Az.CognitiveServices Core,Desk {Get-AzCognitiveServicesAccount, Get-AzCognitiveSe…
Script 2.2.0 Az.Compute Core,Desk {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, …
Script 1.3.0 Az.Compute Core,Desk {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, …
Script 1.0.1 Az.ContainerInstance Core,Desk {New-AzContainerGroup, Get-AzContainerGroup, Remov…
Script 1.0.0 Az.ContainerInstance Core,Desk {New-AzContainerGroup, Get-AzContainerGroup, Remov…
Script 1.0.1 Az.ContainerRegistry Core,Desk {New-AzContainerRegistry, Get-AzContainerRegistry,…
Script 1.1.1 Az.DataFactory Core,Desk {Set-AzDataFactoryV2, Update-AzDataFactoryV2, Get-…
Script 1.0.1 Az.DataFactory Core,Desk {Set-AzDataFactoryV2, Update-AzDataFactoryV2, Get-…
Script 1.0.0 Az.DataLakeAnalytics Core,Desk {Get-AzDataLakeAnalyticsDataSource, New-AzDataLake…
Script 1.2.1 Az.DataLakeStore Core,Desk {Get-AzDataLakeStoreTrustedIdProvider, Remove-AzDa…
Script 1.0.2 Az.DataLakeStore Core,Desk {Get-AzDataLakeStoreTrustedIdProvider, Remove-AzDa…
Script 1.0.0 Az.DeploymentManager Core,Desk {Get-AzDeploymentManagerArtifactSource, New-AzDepl…
Script 1.0.0 Az.DevTestLabs Core,Desk {Get-AzDtlAllowedVMSizesPolicy, Get-AzDtlAutoShutd…
Script 1.1.0 Az.Dns Core,Desk {Get-AzDnsRecordSet, New-AzDnsRecordConfig, Remove…
Script 1.0.0 Az.Dns Core,Desk {Get-AzDnsRecordSet, New-AzDnsRecordConfig, Remove…
Script 1.1.1 Az.EventGrid Core,Desk {New-AzEventGridTopic, Get-AzEventGridTopic, Set-A…
Script 1.1.0 Az.EventGrid Core,Desk {New-AzEventGridTopic, Get-AzEventGridTopic, Set-A…
Script 1.2.0 Az.EventHub Core,Desk {New-AzEventHubNamespace, Get-AzEventHubNamespace,…
Script 1.0.0 Az.EventHub Core,Desk {New-AzEventHubNamespace, Get-AzEventHubNamespace,…
Script 1.0.0 Az.FrontDoor Core,Desk {New-AzFrontDoor, Get-AzFrontDoor, Set-AzFrontDoor…
Script 2.0.0 Az.HDInsight Core,Desk {Get-AzHDInsightJob, New-AzHDInsightSqoopJobDefini…
Script 1.0.0 Az.HDInsight Core,Desk {Get-AzHDInsightJob, New-AzHDInsightSqoopJobDefini…
Script 1.1.0 Az.IotHub Core,Desk {Add-AzIotHubKey, Get-AzIotHubEventHubConsumerGrou…
Script 1.0.2 Az.IotHub Core,Desk {Add-AzIotHubKey, Get-AzIotHubEventHubConsumerGrou…
Script 1.2.0 Az.KeyVault Core,Desk {Add-AzKeyVaultCertificate, Update-AzKeyVaultCerti…
Script 1.0.1 Az.KeyVault Core,Desk {Add-AzKeyVaultCertificate, Update-AzKeyVaultCerti…
Script 1.2.1 Az.LogicApp Core,Desk {Get-AzIntegrationAccountAgreement, Get-AzIntegrat…
Script 1.1.0 Az.LogicApp Core,Desk {Get-AzIntegrationAccountAgreement, Get-AzIntegrat…
Script 1.1.0 Az.MachineLearning Core,Desk {Move-AzMlCommitmentAssociation, Get-AzMlCommitmen…
Script 1.0.0 Az.MachineLearning Core,Desk {Move-AzMlCommitmentAssociation, Get-AzMlCommitmen…
Script 1.0.0 Az.MarketplaceOrdering Core,Desk {Get-AzMarketplaceTerms, Set-AzMarketplaceTerms}
Script 1.1.0 Az.Media Core,Desk {Sync-AzMediaServiceStorageKey, Set-AzMediaService…
Script 1.0.0 Az.Media Core,Desk {Sync-AzMediaServiceStorageKeys, Set-AzMediaServic…
Script 1.2.1 Az.Monitor Core,Desk {Get-AzMetricDefinition, Get-AzMetric, Remove-AzLo…
Script 1.0.0 Az.Monitor Core,Desk {Get-AzMetricDefinition, Get-AzMetric, Remove-AzLo…
Script 1.9.0 Az.Network Core,Desk {Add-AzApplicationGatewayAuthenticationCertificate…
Script 1.1.0 Az.Network Core,Desk {Add-AzApplicationGatewayAuthenticationCertificate…
Script 1.1.0 Az.NotificationHubs Core,Desk {Get-AzNotificationHub, Get-AzNotificationHubAutho…
Script 1.0.0 Az.NotificationHubs Core,Desk {Get-AzNotificationHub, Get-AzNotificationHubAutho…
Script 1.2.0 Az.OperationalInsights Core,Desk {New-AzOperationalInsightsAzureActivityLogDataSour…
Script 1.0.0 Az.OperationalInsights Core,Desk {New-AzOperationalInsightsAzureActivityLogDataSour…
Script 1.1.1 Az.PolicyInsights Core,Desk {Get-AzPolicyEvent, Get-AzPolicyState, Get-AzPolic…
Script 1.0.0 Az.PolicyInsights Core,Desk {Get-AzPolicyEvent, Get-AzPolicyState, Get-AzPolic…
Script 1.1.0 Az.PowerBIEmbedded Core,Desk {Remove-AzPowerBIWorkspaceCollection, Get-AzPowerB…
Script 1.0.0 Az.PowerBIEmbedded Core,Desk {Remove-AzPowerBIWorkspaceCollection, Get-AzPowerB…
Script 1.4.1 Az.RecoveryServices Core,Desk {Get-AzRecoveryServicesBackupProperty, Get-AzRecov…
Script 1.0.0 Az.RecoveryServices Core,Desk {Get-AzRecoveryServicesBackupProperty, Get-AzRecov…
Script 1.1.0 Az.RedisCache Core,Desk {Remove-AzRedisCachePatchSchedule, New-AzRedisCach…
Script 1.0.0 Az.RedisCache Core,Desk {Remove-AzRedisCachePatchSchedule, New-AzRedisCach…
Script 1.0.1 Az.Relay Core,Desk {New-AzRelayNamespace, Get-AzRelayNamespace, Set-A…
Script 1.0.0 Az.Relay Core,Desk {New-AzRelayNamespace, Get-AzRelayNamespace, Set-A…
Script 1.4.0 Az.Resources Core,Desk {Get-AzProviderOperation, Remove-AzRoleAssignment,…
Script 1.1.2 Az.Resources Core,Desk {Get-AzProviderOperation, Remove-AzRoleAssignment,…
Script 1.2.0 Az.ServiceBus Core,Desk {New-AzServiceBusNamespace, Get-AzServiceBusNamesp…
Script 1.0.0 Az.ServiceBus Core,Desk {New-AzServiceBusNamespace, Get-AzServiceBusNamesp…
Script 1.1.0 Az.ServiceFabric Core,Desk {Add-AzServiceFabricApplicationCertificate, Add-Az…
Script 1.0.1 Az.ServiceFabric Core,Desk {Add-AzServiceFabricApplicationCertificate, Add-Az…
Script 1.0.2 Az.SignalR Core,Desk {New-AzSignalR, Get-AzSignalR, Get-AzSignalRKey, N…
Script 1.11.0 Az.Sql Core,Desk {Get-AzSqlDatabaseTransparentDataEncryption, Get-A…
Script 1.2.0 Az.Sql Core,Desk {Get-AzSqlDatabaseTransparentDataEncryption, Get-A…
Script 1.3.0 Az.Storage Core,Desk {Get-AzStorageAccount, Get-AzStorageAccountKey, Ne…
Script 1.0.2 Az.Storage Core,Desk {Get-AzStorageAccount, Get-AzStorageAccountKey, Ne…
Script 1.0.0 Az.StreamAnalytics Core,Desk {Get-AzStreamAnalyticsFunction, Get-AzStreamAnalyt…
Script 1.0.1 Az.TrafficManager Core,Desk {Add-AzTrafficManagerCustomHeaderToEndpoint, Remov…
Script 1.2.2 Az.Websites Core,Desk {Get-AzAppServicePlan, Set-AzAppServicePlan, New-A…
Script 1.1.0 Az.Websites Core,Desk {Get-AzAppServicePlan, Set-AzAppServicePlan, New-A…
Debug output
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
+ ~~~~~~~~~~~~~~~~~