When trying to run the script on a PowerShell 7 system using either a pre-made App registration or just the default, I get the error message that Connect-MSGraph can't load a type, which means the connection doesn't get started and all else just fails horribly:
$tenant = 'tenantid'
$appid = 'appid'
$secret = 'secret'
Invoke-IntuneDocumentation `
-FullDocumentationPath c:\temp\IntuneDoc.docx `
-ClientId $appid `
-ClientSecret $secret `
-Tenant $tenant
Connect-MSGraph: C:\Users\username\Documents\PowerShell\Modules\IntuneDocumentation\2.0.19\Functions\Invoke-IntuneDocumentation.ps1:94:9
Line |
94 | Connect-MSGraph -ClientSecret $ClientSecret -Quiet
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
InvalidOperation: C:\Users\username\Documents\PowerShell\Modules\IntuneDocumentation\2.0.19\Internal\Get-MobileAppsBeta.ps1:18:9
Line |
18 | $errorResponse = $ex.Response.GetResponseStream()
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| You cannot call a method on a null-valued expression.
The exact same happens when running
Invoke-IntuneDocumentation -FullDocumentationPath C:\temp\testdoc.docx
Line |
96 | Connect-MSGraph
| ~~~~~~~~~~~~~~~
| Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
InvalidOperation: C:\Users\username\Documents\PowerShell\Modules\IntuneDocumentation\2.0.19\Internal\Get-MobileAppsBeta.ps1:18:9
Line |
18 | $errorResponse = $ex.Response.GetResponseStream()
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| You cannot call a method on a null-valued expression.
Get-DeviceAppManagement_ManagedAppPolicies: C:\Users\username\Documents\PowerShell\Modules\IntuneDocumentation\2.0.19\Functions\Invoke-IntuneDocumentation.ps1:153:13
Line |
153 | $MAMs = Get-IntuneAppProtectionPolicy | Where-Object { $_.'@odata …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Not authenticated. Please use the "Connect-MSGraph" command to authenticate.
A little bit of digging shows that this seems to be a Connect-MSGraph related issue on PS "core" edition as you can find here.
$psversiontable
Name Value
---- -----
PSVersion 7.1.2
PSEdition Core
GitCommitId 7.1.2
OS Microsoft Windows 10.0.19041
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Running the exact same code under Windows PowerShell works just fine.
Please try again with the new Automatic Microsoft 365 Documentation. We do no longer rely on the Intune Module and therefore it could work. But I have no test environment currently.
When trying to run the script on a PowerShell 7 system using either a pre-made App registration or just the default, I get the error message that Connect-MSGraph can't load a type, which means the connection doesn't get started and all else just fails horribly:
The exact same happens when running
A little bit of digging shows that this seems to be a Connect-MSGraph related issue on PS "core" edition as you can find here.
Running the exact same code under Windows PowerShell works just fine.
Suggestion is to either update documentation that Windows PowerShell is required or perhaps another solution/workaround for this issue.