mattcourtman Posted June 19, 2023 Posted June 19, 2023 Hi I'm trying to create a JSON file for the Autopilot profiles in our environment. I'm following this MS guide: https://learn.microsoft.com/en-us/mem/autopilot/existing-devices#install-required-modules These bits work ok: Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -ForceInstall-Module AzureAD -ForceInstall-Module Microsoft.Graph.Intune -ForceInstall-Module WindowsAutopilotIntune -ForceImport-Module AzureADImport-Module Microsoft.Graph.IntuneImport-Module WindowsAutopilotIntuneConnect-MSGraph I login and then run... PS C:\Windows\system32> Get-AutopilotProfile | ConvertTo-AutopilotConfigurationJSON but this is when it errors out.... Get-MgOrganization : The term 'Get-MgOrganization' 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\WindowsAutopilotIntune\5.3\WindowsAutoPilotIntune.psm1:585 char:25+ $script:TenantOrg = Get-MgOrganization+ ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-MgOrganization:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Get-MgDomain : The term 'Get-MgDomain' 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\WindowsAutopilotIntune\5.3\WindowsAutoPilotIntune.psm1:586 char:26+ $script:allDomains = Get-MgDomain -All+ ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-MgDomain:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Get-AutopilotProfile : Microsoft.Graph.PowerShell.Authentication.Helpers.HttpResponseException: Response status code does not indicate success: Forbidden (Forbidden). at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)At line:1 char:1+ Get-AutopilotProfile | ConvertTo-AutopilotConfigurationJSON+ ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: ( [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-AutopilotProfile Can anyone point me in the right direction? Thanks, Matt
chaplic Posted June 20, 2023 Posted June 20, 2023 Needs MS Graph Powershell Module Install the Microsoft Graph PowerShell SDK | Microsoft Learn
jslate1980 Posted June 21, 2023 Posted June 21, 2023 Have you set permissions for Microsoft graph? https://andrewstaylor.com/2023/06/13/authenticating-to-new-get-windowsautopilotinfo/
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now