error running (Get-WindowsAutopilotInfo.ps1)

Rabii BENABDALLAH 21 Reputation points
2022-06-29T14:48:39.023+00:00

Hello i am trying to import a device into intune using the script on Microsoft Gallery but i am getting the error below :

+CategoryInfo : Not Enabled : (:) [New-CimSession], CimException
+FullyQualifiedErrorID :HRESULT 0X803380e4, Microsoft.Management.Infrastructure.CimCmdlets.NewCimSessionCommand
+PSComputerName : -3
Get-CimInstance : Impossible de lier l'argument au paramètre « CimSession», car il a la valeur Null.
Au caractère C:\Program Files\WindowsPowershell\Scripts\Get-WindowsAutoPilotInfo.ps1:208 :42

  • $serial = (Get-CimInstance -CimSession $session -Class Win32_ ...
  • ~~~~~~~~~~~~~~~~~~~
    +CategoryInfo : InvalidData : ( : ) [Get-CimInstance], ParameterBindingValidationException
    +FullyQualifiedErrorID : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Management.Infrastructure.CimCmDlets.GetCimInstanceCommand

I got the window to sign in and used my admin account to do it and then got the error message .
Could you help please

Windows Autopilot
Windows Autopilot
A collection of Microsoft technologies used to set up and pre-configure new devices and to reset, repurpose, and recover devices.
471 questions
0 comments No comments
{count} votes

Accepted answer
  1. Pavel yannara Mirochnitchenko 12,606 Reputation points MVP
    2022-07-04T11:20:56.24+00:00

    I believe you have an error in your line:

    install -script Get-WindowsAutopilotInfo.ps1 -3 -online

    If fails because -3 you put there.

    0 comments No comments

6 additional answers

Sort by: Most helpful
  1. Lu Dai-MSFT 28,411 Reputation points
    2022-06-30T03:14:54.917+00:00

    @Rabii BENABDALLAH Thanks for posting in our Q&A.

    Honestly, I'm not familiar with the error message in PowerShell. However, I can share some information about how I get it.

    I usually run Windows PowerShell ISE as administrator and run the following commands. Then I will get the csv file(in c:\device) about the device information.

    New-Item -Type Directory -Path "C:\device"  
    Set-Location -Path "C:\device"  
    $env:Path += ";C:\Program Files\WindowsPowerShell\Scripts"  
    Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned  
    Install-Script -Name Get-WindowsAutopilotInfo  
    Get-WindowsAutopilotInfo -OutputFile AutopilotHWID.csv  
    

    216324-image.png

    216431-image.png

    Hope it will help.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Rabii BENABDALLAH 21 Reputation points
    2022-06-30T07:03:09.417+00:00

    @Lu Dai-MSFT
    Hey , thank you for your answer.
    the script you mentionned works fine but we need to add a tag to the device so that it is moved to a dynamic group.
    the command am using is install -script Get-WindowsAutopilotInfo.ps1 -3 -online and just after entering my credentials i got the error msg.


  3. Rudy Ooms 611 Reputation points MVP
    2022-07-04T10:27:15.487+00:00

    This is due to the 2022-05 updates breaking things :)

    after install KB5013942 - 2022-05 Cumulative Update for Windows 10 Version 21H2 this issue started occurring... not sure if the june update fixes it but.. uninstalling that update will also fix it

    0 comments No comments

  4. Rabii BENABDALLAH 21 Reputation points
    2022-07-05T11:15:02.84+00:00

    @Rudy Ooms thank you for your answer. Indeed i checked that update and it is not installed on the device.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.