Open
Description
Description
Getting new error, not sure how to get past it:
$managementGroups = Get-AzManagementGroup
| ~~~~~~~~~~~~~~~~~~~~~
| Value cannot be null. (Parameter 'g')
Issue script & Debug output
$managementGroups = Get-AzManagementGroup
DEBUG: Initializing ConditionalAssemblyContext. PSEdition is [Core]. PSVersion is [7.5.0].
DEBUG: Initializing ConditionalAssemblyProvider. AssemblyRootPath is [/Users/jasonbreetz/.local/share/powershell/Modules/Az.Accounts/4.0.2/StartupScripts/../lib].
DEBUG: Registering Az shared AssemblyLoadContext.
DEBUG: AssemblyLoadContext registered.
DEBUG: Initializing PSStyle.
DEBUG: Got version 0 of Az
DEBUG: Got version 0 of Az.Accounts
DEBUG: 11:29:20 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 11:29:20 AM - GetAzureRmManagementGroup begin processing with ParameterSet 'ListOperation'.
DEBUG: 11:29:20 AM - using account id 'JasonBreetz@EntroSecEngineering.onmicrosoft.com'...
DEBUG: 11:29:20 AM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.Resources], Cmdlet = [Get-AzManagementGroup]. Returning default value [True].
DEBUG: 11:29:20 AM - [ConfigManager] Got nothing from [EnableErrorRecordsPersistence], Module = [Az.Resources], Cmdlet = [Get-AzManagementGroup]. Returning default value [False].
Get-AzManagementGroup: Value cannot be null. (Parameter 'g')
DEBUG: 11:29:20 AM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.Resources], Cmdlet = [Get-AzManagementGroup]. Returning default value [True].
DEBUG: 11:29:20 AM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 11:29:20 AM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.Resources:7.8.1; CommandName: Get-AzManagementGroup; PSVersion: 7.5.0; IsSuccess: False; Duration: 00:00:00.0683252; SanitizeDuration: 00:00:00; Exception: Value cannot be null. (Parameter 'g');
DEBUG: 11:29:20 AM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 11:29:20 AM - GetAzureRmManagementGroup end processing.
Environment data
Name Value
---- -----
PSVersion 7.5.0
PSEdition Core
GitCommitId 7.5.0
OS Darwin 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan 2 20:23:36 PST 2025; root:xnu-11215.81.4~3/RELEASE_A…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Module versions
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 4.0.2 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefaul…
Script 7.8.1 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignmen…
Error output
DEBUG: 11:31:44 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 11:31:44 AM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 11:31:44 AM - using account id 'JasonBreetz@EntroSecEngineering.onmicrosoft.com'...
DEBUG: 11:31:44 AM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [Az.Accounts], Cmdlet = [Resolve-AzError]. Returning default value [True].
DEBUG: 11:31:44 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
HistoryId: 3
Message : Value cannot be null. (Parameter 'g')
StackTrace : at System.ArgumentNullException.Throw(String paramName)
at System.Guid..ctor(String g)
at Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.GetServiceClientCredentials(IAzureC
ontext context, String targetEndpoint, String resourceId)
at Microsoft.Azure.Commands.Common.Authentication.Factories.AuthenticationFactory.GetServiceClientCredentials(IAzureC
ontext context, String targetEndpoint)
at Microsoft.Azure.Commands.Common.Authentication.Factories.ClientFactory.CreateArmClient[TClient](IAzureContext
context, String endpoint)
at Microsoft.Azure.Commands.Resources.ManagementGroups.Common.AzureManagementGroupsCmdletBase.get_ManagementGroupsApi
Client()
at Microsoft.Azure.Commands.Resources.ManagementGroups.GetAzureRmManagementGroup.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.ArgumentNullException
InvocationInfo : {Get-AzManagementGroup}
Line : $managementGroups = Get-AzManagementGroup
Position : At line:1 char:25
+ $managementGroups = Get-AzManagementGroup
+ ~~~~~~~~~~~~~~~~~~~~~
HistoryId : 3
DEBUG: 11:31:44 AM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 11:31:44 AM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.Accounts:4.0.2; CommandName: Resolve-AzError; PSVersion: 7.5.0; IsSuccess: True; Duration: 00:00:00.0172944; SanitizeDuration: 00:00:00.0028980
DEBUG: 11:31:44 AM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 11:31:44 AM - ResolveError end processing.
Activity
isra-fel commentedon Feb 20, 2025
Hi, could you check if tenant ID is correctly set by
get-azcontext | fl
?donttread0nme commentedon Feb 21, 2025
Hi @isra-fel
Here's the output:
get-azcontext | fl
Name : Subscription 1 (6cc78aa9-0d4f-4e7a-ba79-b283ec396eb6) - - <>
Subscription : 6cc78aa9-0d4f-4e7a-ba79-b283ec396eb6
Account : <>
Environment : AzureCloud
Tenant :
TokenCache :
VersionProfile :
ExtendedProperties : {}
OFalcken commentedon May 16, 2025
Hello, I have had the same issue as you for a looooooong time and finally found the solution after reading this post.
The issue here (I assume) is that when you run Connect-AzAccount and login via the prompt your tenant ID is never set. This is the issue for me atleast.
This causes all subsequent AZ comamndos to return: Value cannot be null. (Parameter 'g')
My working solution is to still run the Connect-AzAccount command but specify the tenant:
Connect-AzAccount -Tenant "xxxxxx-xxxx-xxx-xxxx"
OranguTech commentedon Jun 17, 2025
Thank you @OFalcken - this was driving me crazy - not sure how my available contexts got so goofed up.
I think this should be turned into a feature enhancement request (though I'd argue such an unhelpful/incorrect error message such as
Get-AzResourceGroup: Value cannot be null. (Parameter 'g')
should be classed a bug.