The term 'Get-MgServicePrincipalCount' is not recognized as the name of a cmdlet,"
Describe the bug
Hi,
I just ran this for the first time, running the latest version of MSIdentityTools.
Am I missing a dependency?
Running on Windows 10 with PS version 5.1
PS C:\temp> Install-Module -Name MSIdentityTools PS C:\temp> Install-Module -Name ImportExcel PS C:\temp> Connect-MgGraph -Scopes Application.Read.All Welcome to Microsoft Graph!
....
PS C:\temp> Export-MsIdAppConsentGrantReport -ReportOutputType ExcelWorkbook -ExcelWorkbookPath .\appaccess.xlsx
Get-MgServicePrincipalCount : The term 'Get-MgServicePrincipalCount' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files\WindowsPowerShell\Modules\MSIdentityTools\2.0.52\MSIdentityTools.psm1:2900 char:18
-
$count = Get-MgServicePrincipalCount -ConsistencyLevel eventu ... -
~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : ObjectNotFound: (Get-MgServicePrincipalCount:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
Get-MgServicePrincipal : The term 'Get-MgServicePrincipal' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files\WindowsPowerShell\Modules\MSIdentityTools\2.0.52\MSIdentityTools.psm1:2904 char:37
-
$script:ServicePrincipals = Get-MgServicePrincipal -ExpandPro ... -
~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : ObjectNotFound: (Get-MgServicePrincipal:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
The variable '$script:ServicePrincipals' cannot be retrieved because it has not been set. At C:\Program Files\WindowsPowerShell\Modules\MSIdentityTools\2.0.52\MSIdentityTools.psm1:2971 char:29
-
foreach ($client in $script:ServicePrincipals) { -
~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : InvalidOperation: (script:ServicePrincipals:String) [], RuntimeException
- FullyQualifiedErrorId : VariableIsUndefined
The variable '$script:servicePrincipals' cannot be retrieved because it has not been set. At C:\Program Files\WindowsPowerShell\Modules\MSIdentityTools\2.0.52\MSIdentityTools.psm1:3013 char:30
-
$servicePrincipals = $script:servicePrincipals -
~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : InvalidOperation: (script:servicePrincipals:String) [], RuntimeException
- FullyQualifiedErrorId : VariableIsUndefined
The variable '$script:servicePrincipals' cannot be retrieved because it has not been set. At C:\Program Files\WindowsPowerShell\Modules\MSIdentityTools\2.0.52\MSIdentityTools.psm1:3021 char:16
-
$job = $script:servicePrincipals | ForEach-Object -AsJob -Thr ... -
~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : InvalidOperation: (script:servicePrincipals:String) [], RuntimeException
- FullyQualifiedErrorId : VariableIsUndefined
The property 'State' cannot be found on this object. Verify that the property exists. At C:\Program Files\WindowsPowerShell\Modules\MSIdentityTools\2.0.52\MSIdentityTools.psm1:3042 char:16
-
while ($job.State -eq 'Running') { -
~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
- FullyQualifiedErrorId : PropertyNotFoundStrict
An error occurred while retrieving app consent grants. Please try again. At C:\Program Files\WindowsPowerShell\Modules\MSIdentityTools\2.0.52\MSIdentityTools.psm1:2891 char:13
-
throw "An error occurred while retrieving app consent gra ... -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : OperationStopped: (An error occurr...ease try again.:String) [], RuntimeException
- FullyQualifiedErrorId : An error occurred while retrieving app consent grants. Please try again.
I was able to resolve this by running:
install-module Microsoft.Graph.Applications