Finding Entra commands with Get-Command is very slow
Finding Entra commands with Get-Command is very slow compared to other commands. After starting fresh, new PowerShell session:
PS C:\> h
Id Duration CommandLine
-- -------- -----------
1 3.391 Get-Command Update-MgUser -Syntax
2 37.114 Get-Command Set-EntraUser -Syntax
@alexandair Thanks for raising the bug we are looking into it.
@rtintor @KenitoInc : can u plz chekc this issue.
I can consistently reproduce this slowness as well.
It is loading every module dependency before returning the list of commands in the module. After running this test many times in new PowerShell sessions but no reboot, the average time did gradually go down from ~20 seconds to ~12 seconds. Is there any way to optimize this?
Can we clarify a few things?
- Is the slowness only when the module is not yet loaded? Does subsequent
get-commandusage for commands already loaded show impact? Would be good to just usemeasure-objecton a few runs and get the statistics. It sounds like it's only the first time the command has been accessed to me, but that's not explicitly stated yet. - How does it compare to the time for loading those same ms graph ps sdk modules? Is it about the same? I would expect it to be, but we should measure
- How does it compare to the speed of comparable legacy modules, e.g.
AzureADandAzureADPreviewmodules? I'm guessing it's slower, but it would be great to measure both and compare.
@adamedx Yes, the slowness is experienced when the module is not yet loaded. First run in freshly started PowerShell session is slow. Subsequent runs are fast (modules are already loaded).
PS> Get-Command Get-EntraUser
CommandType Name
----------- ----
Function Get-EntraUser
PS> Get-Command Get-EntraUser
CommandType Name
----------- ----
Function Get-EntraUser
PS> Get-Command Get-EntraUser
CommandType Name
----------- ----
Function Get-EntraUser
PS> Get-Command Get-EntraGroup
CommandType Name
----------- ----
Function Get-EntraGroup
PS> h
Id Duration CommandLine
-- -------- -----------
1 56.445 Get-Command Get-EntraUser
2 0.009 Get-Command Get-EntraUser
3 0.009 Get-Command Get-EntraUser
4 0.027 Get-Command Get-EntraGroup
Here is the list of loaded modules after running Get-Command <Entra command>:
PS> gmo
ModuleType Version PreRelease Name
---------- ------- ---------- ----
Script 2.19.0 Microsoft.Graph.Applications
Script 2.19.0 Microsoft.Graph.Authentication
Script 0.10.0 preview Microsoft.Graph.Entra
Script 2.19.0 Microsoft.Graph.Groups
Script 2.19.0 Microsoft.Graph.Identity.Directory
Script 2.19.0 Microsoft.Graph.Identity.Governanc
Script 2.19.0 Microsoft.Graph.Identity.SignIns
Script 2.19.0 Microsoft.Graph.Users
Script 2.19.0 Microsoft.Graph.Users.Actions
Script 2.19.0 Microsoft.Graph.Users.Functions
Manifest 7.0.0.0 Microsoft.PowerShell.Management
Manifest 7.0.0.0 Microsoft.PowerShell.Utility
Script 2.3.5 PSReadLine
For some reason, it's even slower for Entra beta commands:
PS> Get-Command Get-EntraBetaUser
CommandType Name
----------- ----
Function Get-EntraBetaUser
PS> h
Id Duration CommandLine
-- -------- -----------
1 56.445 Get-Command Get-EntraUser
2 0.009 Get-Command Get-EntraUser
3 0.009 Get-Command Get-EntraUser
4 0.027 Get-Command Get-EntraGroup
5 0.048 h
6 0.071 gmo
7 2:44.399 Get-Command Get-EntraBetaUser
PS> gmo
ModuleType Version PreRelease Name
---------- ------- ---------- ----
Script 2.19.0 Microsoft.Graph.Applications
Script 2.19.0 Microsoft.Graph.Authentication
Script 2.19.0 Microsoft.Graph.Beta.Applications
Script 2.19.0 Microsoft.Graph.Beta.Groups
Script 2.19.0 Microsoft.Graph.Beta.Identity.Dire
Script 2.19.0 Microsoft.Graph.Beta.Identity.Gove
Script 2.19.0 Microsoft.Graph.Beta.Identity.Sign
Script 2.19.0 Microsoft.Graph.Beta.Reports
Script 2.19.0 Microsoft.Graph.Beta.Users
Script 2.19.0 Microsoft.Graph.Beta.Users.Actions
Script 2.19.0 Microsoft.Graph.Beta.Users.Functio
Script 0.10.0 preview Microsoft.Graph.Entra
Script 0.10.0 preview Microsoft.Graph.Entra.Beta
Script 2.19.0 Microsoft.Graph.Groups
Script 2.19.0 Microsoft.Graph.Identity.Directory
Script 2.19.0 Microsoft.Graph.Identity.Governanc
Script 2.19.0 Microsoft.Graph.Identity.SignIns
Script 2.19.0 Microsoft.Graph.Users
Script 2.19.0 Microsoft.Graph.Users.Actions
Script 2.19.0 Microsoft.Graph.Users.Functions
Manifest 7.0.0.0 Microsoft.PowerShell.Management
Manifest 7.0.0.0 Microsoft.PowerShell.Utility
Script 2.3.5 PSReadLine
Running Get-Command <AzureAD command> or Get-Command <Mg command> is fast:
PS> h | fl
Id : 1
CommandLine : Get-Command Get-AzureADUser
ExecutionStatus : Completed
StartExecutionTime : 7/11/2024 1:18:41 PM
EndExecutionTime : 7/11/2024 1:18:42 PM
Id : 2
CommandLine : Get-Command Get-AzureADUser
ExecutionStatus : Completed
StartExecutionTime : 7/11/2024 1:18:44 PM
EndExecutionTime : 7/11/2024 1:18:44 PM
As added context, I have found that if the depended/required modules are already imported (either manually or from another module in the same session), that also reduces the time to either import this module or run Get-Command for this module.
@alexandair + @SamErde: We made some improvements in the last release. We have observed some performance improvements. Could you confirm if this is consistent from your side too?
I don't see any changes in 0.15.0-preview compared to the previous tests.
PS> Get-Command Get-EntraUser
CommandType Name
----------- ----
Function Get-EntraUser
PS> Get-Command Get-EntraUser
CommandType Name
----------- ----
Function Get-EntraUser
PS> Get-Command Get-EntraUser
CommandType Name
----------- ----
Function Get-EntraUser
PS> Get-Command Get-EntraGroup
CommandType Name
----------- ----
Function Get-EntraGroup
PS> h
Id Duration CommandLine
-- -------- -----------
1 51.933 Get-Command Get-EntraUser
2 0.015 Get-Command Get-EntraUser
3 0.007 Get-Command Get-EntraUser
4 0.028 Get-Command Get-EntraGroup
I am seeing the same kind of results as Aleksandar. The first execution of any cmdlet from the module or the first execution of Get-Command targeting the module takes 45~52 seconds to run if the module has not already been imported. After the module has been imported (along with all of its required modules) it only takes a few ms to get the commands.
Would it be feasible and acceptable to remove some of the strict module requirements from the manifest and only import them when necessary? This may require additional code in the modules that reference them, but would make a lot of use cases much faster if they don't have to always load the whole list:
"requiredModules" : [
"Microsoft.Graph.Users",
"Microsoft.Graph.Users.Actions",
"Microsoft.Graph.Users.Functions",
"Microsoft.Graph.Groups",
"Microsoft.Graph.Identity.DirectoryManagement",
"Microsoft.Graph.Identity.Governance",
"Microsoft.Graph.Identity.SignIns",
"Microsoft.Graph.Applications",
"Microsoft.Graph.Reports"
],
"requiredModulesVersion": "2.15.0"
Here are my installation and import times for each required Graph module:
❯ h
Id Duration CommandLine
-- -------- -----------
1 0.059 clear
2 12.086 Install-Module -Name "Microsoft.Graph.Users" -Scope CurrentUser -Force
3 7.343 Install-Module -Name "Microsoft.Graph.Users.Actions" -Scope CurrentUser -Force
4 9.055 Install-Module -Name "Microsoft.Graph.Users.Functions" -Scope CurrentUser -Force
5 8.405 Install-Module -Name "Microsoft.Graph.Groups" -Scope CurrentUser -Force
6 9.002 Install-Module -Name "Microsoft.Graph.Identity.DirectoryManagement" -Scope CurrentUser -Force
7 13.802 Install-Module -Name "Microsoft.Graph.Identity.Governance" -Scope CurrentUser -Force
8 7.872 Install-Module -Name "Microsoft.Graph.Identity.SignIns" -Scope CurrentUser -Force
9 8.111 Install-Module -Name "Microsoft.Graph.Applications" -Scope CurrentUser -Force
10 10.154 Install-Module -Name "Microsoft.Graph.Reports" -Scope CurrentUser -Force
11 3.889 Import-Module -Name "Microsoft.Graph.Users"
12 1.964 Import-Module -Name "Microsoft.Graph.Users.Actions"
13 1.286 Import-Module -Name "Microsoft.Graph.Users.Functions"
14 3.899 Import-Module -Name "Microsoft.Graph.Groups"
15 2.896 Import-Module -Name "Microsoft.Graph.Identity.DirectoryManagement"
16 14.347 Import-Module -Name "Microsoft.Graph.Identity.Governance"
17 4.750 Import-Module -Name "Microsoft.Graph.Identity.SignIns"
18 5.094 Import-Module -Name "Microsoft.Graph.Applications"
19 3.588 Import-Module -Name "Microsoft.Graph.Reports"
PowerShell 7.4.5
Transcript started, output file is ~\PowerShell_Logs\20240916T113720.5761-04.log
Loading personal and system profiles took 1933ms.
❯ Install-Module -Name 'Microsoft.Graph.Entra' -AllowPrerelease -Scope CurrentUser
❯ Import-Module -Name 'Microsoft.Graph.Entra' -Verbose
VERBOSE: Loading module from path '~\OneDrive\Documents\PowerShell\Modules\Microsoft.Graph.Entra\0.15.0\Microsoft.Graph.Entra.psd1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Entra.
VERBOSE: Loading module from path '~\OneDrive\Documents\PowerShell\Modules\Microsoft.Graph.Entra\0.15.0\Microsoft.Graph.Entra.psm1'.
VERBOSE: Importing function 'Add-EntraAdministrativeUnitMember'.
VERBOSE: Importing function 'Add-EntraApplicationOwner'.
VERBOSE: Importing function 'Add-EntraCustomSecurityAttributeDefinitionAllowedValue'.
VERBOSE: Importing function 'Add-EntraDeviceRegisteredOwner'.
VERBOSE: Importing function 'Add-EntraDeviceRegisteredUser'.
VERBOSE: Importing function 'Add-EntraDirectoryRoleMember'.
VERBOSE: Importing function 'Add-EntraEnvironment'.
VERBOSE: Importing function 'Add-EntraGroupMember'.
VERBOSE: Importing function 'Add-EntraGroupOwner'.
VERBOSE: Importing function 'Add-EntraLifecyclePolicyGroup'.
VERBOSE: Importing function 'Add-EntraScopedRoleMembership'.
VERBOSE: Importing function 'Add-EntraServicePrincipalDelegatedPermissionClassification'.
VERBOSE: Importing function 'Add-EntraServicePrincipalOwner'.
VERBOSE: Importing function 'Confirm-EntraDomain'.
VERBOSE: Importing function 'Connect-Entra'.
VERBOSE: Importing function 'Disconnect-Entra'.
VERBOSE: Importing function 'Enable-EntraAzureADAlias'.
VERBOSE: Importing function 'Enable-EntraDirectoryRole'.
VERBOSE: Importing function 'Find-EntraPermission'.
VERBOSE: Importing function 'Get-EntraAccountSku'.
VERBOSE: Importing function 'Get-EntraAdministrativeUnit'.
VERBOSE: Importing function 'Get-EntraAdministrativeUnitMember'.
VERBOSE: Importing function 'Get-EntraApplication'.
VERBOSE: Importing function 'Get-EntraApplicationExtensionProperty'.
VERBOSE: Importing function 'Get-EntraApplicationKeyCredential'.
VERBOSE: Importing function 'Get-EntraApplicationLogo'.
VERBOSE: Importing function 'Get-EntraApplicationOwner'.
VERBOSE: Importing function 'Get-EntraApplicationPasswordCredential'.
VERBOSE: Importing function 'Get-EntraApplicationServiceEndpoint'.
VERBOSE: Importing function 'Get-EntraApplicationTemplate'.
VERBOSE: Importing function 'Get-EntraAttributeSet'.
VERBOSE: Importing function 'Get-EntraAuditDirectoryLog'.
VERBOSE: Importing function 'Get-EntraAuditSignInLog'.
VERBOSE: Importing function 'Get-EntraAuthorizationPolicy'.
VERBOSE: Importing function 'Get-EntraConditionalAccessPolicy'.
VERBOSE: Importing function 'Get-EntraContact'.
VERBOSE: Importing function 'Get-EntraContactDirectReport'.
VERBOSE: Importing function 'Get-EntraContactManager'.
VERBOSE: Importing function 'Get-EntraContactMembership'.
VERBOSE: Importing function 'Get-EntraContext'.
VERBOSE: Importing function 'Get-EntraContract'.
VERBOSE: Importing function 'Get-EntraCustomSecurityAttributeDefinition'.
VERBOSE: Importing function 'Get-EntraCustomSecurityAttributeDefinitionAllowedValue'.
VERBOSE: Importing function 'Get-EntraDeletedApplication'.
VERBOSE: Importing function 'Get-EntraDeletedDirectoryObject'.
VERBOSE: Importing function 'Get-EntraDeletedGroup'.
VERBOSE: Importing function 'Get-EntraDevice'.
VERBOSE: Importing function 'Get-EntraDeviceRegisteredOwner'.
VERBOSE: Importing function 'Get-EntraDeviceRegisteredUser'.
VERBOSE: Importing function 'Get-EntraDirectoryObjectOnPremisesProvisioningError'.
VERBOSE: Importing function 'Get-EntraDirectoryRole'.
VERBOSE: Importing function 'Get-EntraDirectoryRoleAssignment'.
VERBOSE: Importing function 'Get-EntraDirectoryRoleDefinition'.
VERBOSE: Importing function 'Get-EntraDirectoryRoleMember'.
VERBOSE: Importing function 'Get-EntraDirectoryRoleTemplate'.
VERBOSE: Importing function 'Get-EntraDirSyncConfiguration'.
VERBOSE: Importing function 'Get-EntraDirSyncfeature'.
VERBOSE: Importing function 'Get-EntraDomain'.
VERBOSE: Importing function 'Get-EntraDomainFederationSettings'.
VERBOSE: Importing function 'Get-EntraDomainNameReference'.
VERBOSE: Importing function 'Get-EntraDomainServiceConfigurationRecord'.
VERBOSE: Importing function 'Get-EntraDomainVerificationDnsRecord'.
VERBOSE: Importing function 'Get-EntraEnvironment'.
VERBOSE: Importing function 'Get-EntraExtensionProperty'.
VERBOSE: Importing function 'Get-EntraFeatureRolloutPolicy'.
VERBOSE: Importing function 'Get-EntraFederationProperty'.
VERBOSE: Importing function 'Get-EntraGroup'.
VERBOSE: Importing function 'Get-EntraGroupAppRoleAssignment'.
VERBOSE: Importing function 'Get-EntraGroupLifecyclePolicy'.
VERBOSE: Importing function 'Get-EntraGroupMember'.
VERBOSE: Importing function 'Get-EntraGroupOwner'.
VERBOSE: Importing function 'Get-EntraGroupPermissionGrant'.
VERBOSE: Importing function 'Get-EntraIdentityProvider'.
VERBOSE: Importing function 'Get-EntraLifecyclePolicyGroup'.
VERBOSE: Importing function 'Get-EntraNamedLocationPolicy'.
VERBOSE: Importing function 'Get-EntraOAuth2PermissionGrant'.
VERBOSE: Importing function 'Get-EntraObjectByObjectId'.
VERBOSE: Importing function 'Get-EntraObjectSetting'.
VERBOSE: Importing function 'Get-EntraPartnerInformation'.
VERBOSE: Importing function 'Get-EntraPasswordPolicy'.
VERBOSE: Importing function 'Get-EntraPermissionGrantConditionSet'.
VERBOSE: Importing function 'Get-EntraPermissionGrantPolicy'.
VERBOSE: Importing function 'Get-EntraPolicy'.
VERBOSE: Importing function 'Get-EntraScopedRoleMembership'.
VERBOSE: Importing function 'Get-EntraServicePrincipal'.
VERBOSE: Importing function 'Get-EntraServicePrincipalAppRoleAssignedTo'.
VERBOSE: Importing function 'Get-EntraServicePrincipalAppRoleAssignment'.
VERBOSE: Importing function 'Get-EntraServicePrincipalCreatedObject'.
VERBOSE: Importing function 'Get-EntraServicePrincipalDelegatedPermissionClassification'.
VERBOSE: Importing function 'Get-EntraServicePrincipalKeyCredential'.
VERBOSE: Importing function 'Get-EntraServicePrincipalMembership'.
VERBOSE: Importing function 'Get-EntraServicePrincipalOAuth2PermissionGrant'.
VERBOSE: Importing function 'Get-EntraServicePrincipalOwnedObject'.
VERBOSE: Importing function 'Get-EntraServicePrincipalOwner'.
VERBOSE: Importing function 'Get-EntraServicePrincipalPasswordCredential'.
VERBOSE: Importing function 'Get-EntraSubscribedSku'.
VERBOSE: Importing function 'Get-EntraTenantDetail'.
VERBOSE: Importing function 'Get-EntraTrustedCertificateAuthority'.
VERBOSE: Importing function 'Get-EntraUnsupportedCommand'.
VERBOSE: Importing function 'Get-EntraUser'.
VERBOSE: Importing function 'Get-EntraUserAppRoleAssignment'.
VERBOSE: Importing function 'Get-EntraUserCreatedObject'.
VERBOSE: Importing function 'Get-EntraUserDirectReport'.
VERBOSE: Importing function 'Get-EntraUserExtension'.
VERBOSE: Importing function 'Get-EntraUserLicenseDetail'.
VERBOSE: Importing function 'Get-EntraUserManager'.
VERBOSE: Importing function 'Get-EntraUserMembership'.
VERBOSE: Importing function 'Get-EntraUserOAuth2PermissionGrant'.
VERBOSE: Importing function 'Get-EntraUserOwnedDevice'.
VERBOSE: Importing function 'Get-EntraUserOwnedObject'.
VERBOSE: Importing function 'Get-EntraUserRegisteredDevice'.
VERBOSE: Importing function 'Get-EntraUserThumbnailPhoto'.
VERBOSE: Importing function 'New-EntraAdministrativeUnit'.
VERBOSE: Importing function 'New-EntraApplication'.
VERBOSE: Importing function 'New-EntraApplicationExtensionProperty'.
VERBOSE: Importing function 'New-EntraApplicationFromApplicationTemplate'.
VERBOSE: Importing function 'New-EntraApplicationKey'.
VERBOSE: Importing function 'New-EntraApplicationKeyCredential'.
VERBOSE: Importing function 'New-EntraApplicationPassword'.
VERBOSE: Importing function 'New-EntraApplicationPasswordCredential'.
VERBOSE: Importing function 'New-EntraAttributeSet'.
VERBOSE: Importing function 'New-EntraConditionalAccessPolicy'.
VERBOSE: Importing function 'New-EntraCustomHeaders'.
VERBOSE: Importing function 'New-EntraCustomSecurityAttributeDefinition'.
VERBOSE: Importing function 'New-EntraDevice'.
VERBOSE: Importing function 'New-EntraDirectoryRoleAssignment'.
VERBOSE: Importing function 'New-EntraDirectoryRoleDefinition'.
VERBOSE: Importing function 'New-EntraDomain'.
VERBOSE: Importing function 'New-EntraFeatureRolloutPolicy'.
VERBOSE: Importing function 'New-EntraGroup'.
VERBOSE: Importing function 'New-EntraGroupAppRoleAssignment'.
VERBOSE: Importing function 'New-EntraGroupLifecyclePolicy'.
VERBOSE: Importing function 'New-EntraIdentityProvider'.
VERBOSE: Importing function 'New-EntraInvitation'.
VERBOSE: Importing function 'New-EntraNamedLocationPolicy'.
VERBOSE: Importing function 'New-EntraOauth2PermissionGrant'.
VERBOSE: Importing function 'New-EntraPermissionGrantConditionSet'.
VERBOSE: Importing function 'New-EntraPermissionGrantPolicy'.
VERBOSE: Importing function 'New-EntraPolicy'.
VERBOSE: Importing function 'New-EntraServicePrincipal'.
VERBOSE: Importing function 'New-EntraServicePrincipalAppRoleAssignment'.
VERBOSE: Importing function 'New-EntraServicePrincipalPasswordCredential'.
VERBOSE: Importing function 'New-EntraTrustedCertificateAuthority'.
VERBOSE: Importing function 'New-EntraUser'.
VERBOSE: Importing function 'New-EntraUserAppRoleAssignment'.
VERBOSE: Importing function 'Remove-EntraAdministrativeUnit'.
VERBOSE: Importing function 'Remove-EntraAdministrativeUnitMember'.
VERBOSE: Importing function 'Remove-EntraApplication'.
VERBOSE: Importing function 'Remove-EntraApplicationExtensionProperty'.
VERBOSE: Importing function 'Remove-EntraApplicationKey'.
VERBOSE: Importing function 'Remove-EntraApplicationKeyCredential'.
VERBOSE: Importing function 'Remove-EntraApplicationOwner'.
VERBOSE: Importing function 'Remove-EntraApplicationPassword'.
VERBOSE: Importing function 'Remove-EntraApplicationPasswordCredential'.
VERBOSE: Importing function 'Remove-EntraApplicationVerifiedPublisher'.
VERBOSE: Importing function 'Remove-EntraConditionalAccessPolicy'.
VERBOSE: Importing function 'Remove-EntraContact'.
VERBOSE: Importing function 'Remove-EntraDeletedApplication'.
VERBOSE: Importing function 'Remove-EntraDeletedDirectoryObject'.
VERBOSE: Importing function 'Remove-EntraDevice'.
VERBOSE: Importing function 'Remove-EntraDeviceRegisteredOwner'.
VERBOSE: Importing function 'Remove-EntraDeviceRegisteredUser'.
VERBOSE: Importing function 'Remove-EntraDirectoryRoleAssignment'.
VERBOSE: Importing function 'Remove-EntraDirectoryRoleDefinition'.
VERBOSE: Importing function 'Remove-EntraDirectoryRoleMember'.
VERBOSE: Importing function 'Remove-EntraDomain'.
VERBOSE: Importing function 'Remove-EntraFeatureRolloutPolicy'.
VERBOSE: Importing function 'Remove-EntraFeatureRolloutPolicyDirectoryObject'.
VERBOSE: Importing function 'Remove-EntraGroup'.
VERBOSE: Importing function 'Remove-EntraGroupAppRoleAssignment'.
VERBOSE: Importing function 'Remove-EntraGroupLifecyclePolicy'.
VERBOSE: Importing function 'Remove-EntraGroupMember'.
VERBOSE: Importing function 'Remove-EntraGroupOwner'.
VERBOSE: Importing function 'Remove-EntraIdentityProvider'.
VERBOSE: Importing function 'Remove-EntraLifecyclePolicyGroup'.
VERBOSE: Importing function 'Remove-EntraNamedLocationPolicy'.
VERBOSE: Importing function 'Remove-EntraOAuth2PermissionGrant'.
VERBOSE: Importing function 'Remove-EntraPermissionGrantConditionSet'.
VERBOSE: Importing function 'Remove-EntraPermissionGrantPolicy'.
VERBOSE: Importing function 'Remove-EntraPolicy'.
VERBOSE: Importing function 'Remove-EntraScopedRoleMembership'.
VERBOSE: Importing function 'Remove-EntraServicePrincipal'.
VERBOSE: Importing function 'Remove-EntraServicePrincipalAppRoleAssignment'.
VERBOSE: Importing function 'Remove-EntraServicePrincipalDelegatedPermissionClassification'.
VERBOSE: Importing function 'Remove-EntraServicePrincipalKeyCredential'.
VERBOSE: Importing function 'Remove-EntraServicePrincipalOwner'.
VERBOSE: Importing function 'Remove-EntraServicePrincipalPasswordCredential'.
VERBOSE: Importing function 'Remove-EntraTrustedCertificateAuthority'.
VERBOSE: Importing function 'Remove-EntraUser'.
VERBOSE: Importing function 'Remove-EntraUserAppRoleAssignment'.
VERBOSE: Importing function 'Remove-EntraUserExtension'.
VERBOSE: Importing function 'Remove-EntraUserManager'.
VERBOSE: Importing function 'Reset-EntraLifeCycleGroup'.
VERBOSE: Importing function 'Restore-EntraDeletedApplication'.
VERBOSE: Importing function 'Restore-EntraDeletedDirectoryObject'.
VERBOSE: Importing function 'Revoke-EntraSignedInUserAllRefreshToken'.
VERBOSE: Importing function 'Revoke-EntraUserAllRefreshToken'.
VERBOSE: Importing function 'Select-EntraGroupIdsContactIsMemberOf'.
VERBOSE: Importing function 'Select-EntraGroupIdsGroupIsMemberOf'.
VERBOSE: Importing function 'Select-EntraGroupIdsServicePrincipalIsMemberOf'.
VERBOSE: Importing function 'Select-EntraGroupIdsUserIsMemberOf'.
VERBOSE: Importing function 'Set-EntraAdministrativeUnit'.
VERBOSE: Importing function 'Set-EntraApplication'.
VERBOSE: Importing function 'Set-EntraApplicationLogo'.
VERBOSE: Importing function 'Set-EntraApplicationVerifiedPublisher'.
VERBOSE: Importing function 'Set-EntraAttributeSet'.
VERBOSE: Importing function 'Set-EntraAuthorizationPolicy'.
VERBOSE: Importing function 'Set-EntraConditionalAccessPolicy'.
VERBOSE: Importing function 'Set-EntraCustomSecurityAttributeDefinition'.
VERBOSE: Importing function 'Set-EntraCustomSecurityAttributeDefinitionAllowedValue'.
VERBOSE: Importing function 'Set-EntraDevice'.
VERBOSE: Importing function 'Set-EntraDirectoryRoleDefinition'.
VERBOSE: Importing function 'Set-EntraDirSyncConfiguration'.
VERBOSE: Importing function 'Set-EntraDirSyncFeature'.
VERBOSE: Importing function 'Set-EntraDomain'.
VERBOSE: Importing function 'Set-EntraDomainFederationSettings'.
VERBOSE: Importing function 'Set-EntraFeatureRolloutPolicy'.
VERBOSE: Importing function 'Set-EntraGroup'.
VERBOSE: Importing function 'Set-EntraGroupLifecyclePolicy'.
VERBOSE: Importing function 'Set-EntraIdentityProvider'.
VERBOSE: Importing function 'Set-EntraNamedLocationPolicy'.
VERBOSE: Importing function 'Set-EntraPartnerInformation'.
VERBOSE: Importing function 'Set-EntraPermissionGrantConditionSet'.
VERBOSE: Importing function 'Set-EntraPermissionGrantPolicy'.
VERBOSE: Importing function 'Set-EntraPolicy'.
VERBOSE: Importing function 'Set-EntraServicePrincipal'.
VERBOSE: Importing function 'Set-EntraTenantDetail'.
VERBOSE: Importing function 'Set-EntraTrustedCertificateAuthority'.
VERBOSE: Importing function 'Set-EntraUser'.
VERBOSE: Importing function 'Set-EntraUserExtension'.
VERBOSE: Importing function 'Set-EntraUserLicense'.
VERBOSE: Importing function 'Set-EntraUserManager'.
VERBOSE: Importing function 'Set-EntraUserPassword'.
VERBOSE: Importing function 'Set-EntraUserThumbnailPhoto'.
VERBOSE: Importing function 'Test-EntraScript'.
VERBOSE: Importing function 'Update-EntraSignedInUserPassword'.
VERBOSE: Importing function 'Update-EntraUserFromFederated'.
❯ h
Id Duration CommandLine
-- -------- -----------
1 19.281 Install-Module -Name 'Microsoft.Graph.Entra' -AllowPrerelease -Scope CurrentUser
2 44.754 Import-Module -Name 'Microsoft.Graph.Entra' -Verbose
❯
As you can see, my current test setup unfortunately does have a Documents folder synced to OneDrive (set to 'Always keep on this device'), so to be fair, I'll also test a non-synced location.
The Microsoft Entra PowerShell module loading is still slow. I have put in the profile and this is slowing everything down. Once loaded all good and its fast.
Its talking around 2mins alteast.
Loading personal and system profiles took 411275ms.
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.19.0 Microsoft.Graph.Entra {Add-EntraAdministrativeUnitMember, Add-EntraApplicationOw...
And the module install path is not syncing to OneDrive.
Name : Microsoft.Graph.Entra
Path : C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Entra\0.19.0\Microsoft.Graph.Entra.psm1
Description : Microsoft Graph Entra PowerShell.
ModuleType : Script
Version : 0.19.0
Irrespective of I'm loading a single cmdlet or multiple.
measure-command {Import-Module -Name 'Microsoft.Graph.Entra' -Verbose -Cmdlet Connect-Entra}
VERBOSE: Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\Microsoft.Graph.Entra\0.19.0\Microsoft.Graph.Entra.psd1'.
VERBOSE: Cannot verify the Microsoft .NET Framework version 4.7.2 because it is not included in the list of permitted
versions.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Entra.
VERBOSE: Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\Microsoft.Graph.Entra\0.19.0\Microsoft.Graph.Entra.psm1'.
Days : 0
Hours : 0
Minutes : 2
Seconds : 0
Milliseconds : 129
Ticks : 1201291321
TotalDays : 0.00139038347337963
TotalHours : 0.0333692033611111
TotalMinutes : 2.00215220166667
TotalSeconds : 120.1291321
TotalMilliseconds : 120129.1321
============================
measure-command {Import-Module -Name 'Microsoft.Graph.Entra' -Verbose}
VERBOSE: Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\Microsoft.Graph.Entra\0.19.0\Microsoft.Graph.Entra.psd1'.
VERBOSE: Cannot verify the Microsoft .NET Framework version 4.7.2 because it is not included in the list of permitted
versions.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Entra.
VERBOSE: Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\Microsoft.Graph.Entra\0.19.0\Microsoft.Graph.Entra.psm1'.
VERBOSE: Importing function 'Add-EntraAdministrativeUnitMember'.
VERBOSE: Importing function 'Add-EntraApplicationOwner'.
...
...
Days : 0
Hours : 0
Minutes : 1
Seconds : 50
Milliseconds : 87
Ticks : 1100875510
TotalDays : 0.00127416146990741
TotalHours : 0.0305798752777778
TotalMinutes : 1.83479251666667
TotalSeconds : 110.087551
TotalMilliseconds : 110087.551
The performance problem is fixed in 0.20.0-preview. Module is redesigned and renamed to Microsoft.Entra.
If I were you, I would wait for the next version. Performance of 0.20.0 is much better, but there are some other issues that will be fixed in the next release.
@alexandair thank you for the info, they should update the blogs and articles if they got a newer module, that too if its renamed. Even the reIease notes are not updated. I'll give it a few months, before updating.
https://www.powershellgallery.com/packages/Microsoft.Graph.Entra/0.19.0-preview https://www.powershellgallery.com/packages/Microsoft.Entra/0.20.0-preview
Much improved performance in the latest modules after modularization
> h
Id Duration CommandLine
-- -------- -----------
1 7.649 Get-Command Get-EntraUser
2 0.011 Get-Command Get-EntraUser
3 0.027 Get-Command Get-EntraUser
4 0.010 Get-Command Get-EntraUser
5 0.005 Get-Command Get-EntraUser