Get-AMCAutopilotinfo.ps1
<#PSScriptInfo .VERSION 8.0 .GUID e5464b7b-4ef1-401a-aeac-e8e91ed4b18d .AUTHOR Bibin .COMPANYNAME .COPYRIGHT .TAGS .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES #> <# .DESCRIPTION TestScript to upload the hardware ID to autopilot #> Param() function startrunbook(){ $url = "https://895f518d-f813-48e8-8320-8fde6093c63a.webhook.we.azure-automation.net/webhooks?token=lxN64nsfUtELUlYftGoaPQLYsUpaEpFQu0KSFbZW9BA%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" } |