Last active
October 10, 2024 00:39
-
-
Save DXPetti/860f96d67097b3d23d434fd8ab24f0d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get NuGet provider | |
Install-PackageProvider -Name NuGet -Force | |
# Import NuGet provider | |
Import-PackageProvider -Name NuGet -Force | |
# Get Autopilot Script | |
Install-Script -Name Get-WindowsAutoPilotInfo -Force | |
# Get Az Modules | |
Install-Module -Name Az.Accounts -AllowClobber -Force | |
Install-Module -Name Az.Storage -AllowClobber -Force | |
Install-Module -Name Az.Resources -AllowClobber -Force | |
# Get AzTable Module | |
Install-Module -Name AzTable -Force | |
# Import Az Modules | |
Import-Module -Name Az.Accounts -Force | |
Import-Module -Name Az.Storage -Force | |
Import-Module -Name Az.Resources -Force | |
# Import AzTable Module | |
Import-Module -Name AzTable -Force | |
# Set AzTable connection details | |
$SasUri = "ServiceLevelSasKeyHere" | |
$PartitionKey = 'AutoPilotInfo' | |
try { | |
# Get Autopilot info | |
$Autopilot = Get-WindowsAutopilotInfo.ps1 | |
} | |
catch { | |
Write-Host $_.Exception.Message | |
exit 1 | |
} | |
try { | |
# Connect to AzTable | |
$Uri = [System.Uri]$SasUri | |
$Table= New-Object -TypeName Microsoft.Azure.Cosmos.Table.CloudTable $Uri | |
# Write Autopilot info to table | |
Add-AzTableRow ` | |
-table $Table ` | |
-partitionKey $PartitionKey ` | |
-rowKey ([guid]::NewGuid().tostring()) ` | |
-property @{"DeviceName"="$($env:COMPUTERNAME)";"SerialNumber"="$(($Autopilot).'Device Serial Number')";"Hash"="$(($Autopilot).'Hardware Hash')"} | |
} | |
catch { | |
Write-Host $_.Exception.Message | |
exit 1 | |
} | |
# Set detection key to indicate script has run | |
New-Item -Path 'HKLM:\SOFTWARE\AutoPilotCollection' -Force | |
New-ItemProperty -Path "HKLM:\SOFTWARE\AutoPilotCollection" -Name "AutoPilotInfoCaptured" -Value 1 -PropertyType DWORD -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment