Get-AMCAutopilotinfo.ps1
<#PSScriptInfo .VERSION 7.0 .GUID 8ec7fbc2-be99-47f1-b76b-042d78640a4c .AUTHOR Bibin .COMPANYNAME .COPYRIGHT AMC .TAGS .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES .PRIVATEDATA #> <# .DESCRIPTION The Script is used to upload the windows autopilot informationa to azure version 7. #> function startrunbook(){ $url = "https://895f518d-f813-48e8-8320-8fde6093c63a.webhook.we.azure-automation.net/webhooks?token=iHVMdPXWShI6vzlhcZst%2bJVa5bC9UIgDwoiV8N8Kc%2fw%3d" $session = New-CimSession $serial = (Get-CimInstance -CimSession $session -Class Win32_BIOS).SerialNumber # Get the hash (if available) $devDetail = (Get-CimInstance -CimSession $session -Namespace root/cimv2/mdm/dmmap -Class MDM_DevDetail_Ext01 -Filter "InstanceID='Ext' AND ParentID='./DevDetail'") if ($devDetail -and (-not $Force)) { $hash = $devDetail.DeviceHardwareData } else { $bad = $true $hash = "" } # If the hash isn't available, get the make and model if ($bad -or $Force) { $cs = Get-CimInstance -CimSession $session -Class Win32_ComputerSystem $make = $cs.Manufacturer.Trim() $model = $cs.Model.Trim() if ($Partner) { $bad = $false } } else { $make = "" $model = "" } # Getting the PKID is generally problematic for anyone other than OEMs, so let's skip it here $product = "Autopilot1" $global:DevData = @{SerialNumber = $serial;OrderIdentifier = $product;HardwareHash = $hash} $body = ConvertTo-Json -InputObject $DevData $response =Invoke-RestMethod -Method Post -Uri $url -Body $body return $response.JobIds } write-host "Work In Progress.." Write-Host "********************************************************************" Write-Host "********************************************************************" Write-Host "********************************************************************" #Check the connectivity and call the upload function only if we have the valid connectivity. $Server01="www.google.com" if (Test-Connection $Server01 -Quiet) { $rst = startrunbook Write-Host "Job ID Reference :"$rst if ($rst){ Write-Host "********************************************************************" Write-Host "Hardware ID successfully Uploaded to AZURE, it will take another 15-20 Minutes to replicate in Autopilot" } else{ Write-Host "Failed to Upload the Hardware to azure, please try after sometime" } } else{ Write-Host "Internet Connection not avaiable please try after some time" } |