Skip to content

Instantly share code, notes, and snippets.

@lansalot
Last active August 17, 2021 07:42
Show Gist options
  • Save lansalot/97fc54bdb0f5573427d9efe3d7ee194b to your computer and use it in GitHub Desktop.
Save lansalot/97fc54bdb0f5573427d9efe3d7ee194b to your computer and use it in GitHub Desktop.
If ((gwmi win32_operatingsystem).producttype -gt 1) {
Write-Host "Workstations only. No deal" -Foreground red
exit
}
Set-Location $PSScriptRoot
If (-Not (Test-Path c:\de)) {
mkdir c:\de -force
}
Clear-Host
Start-Transcript c:\de\autohash.log
# Build a library of your Wifi profiles with "netsh wlan export profile folder=."
If (Get-ChildItem WIFI*.xml) {
Write-Host "Found wifi profiles, importing!"
ForEach ($Profile in (Get-ChildItem WIFI*.xml)) {
Write-Host "Importing $($profile.name)"
netsh wlan add profile filename="$($profile.name)"
}
}
cmd /c start ms-availablenetworks:
Write-Host "Now, let's get some internet going.... waiting to establish route."
while ($true) {
If (get-netroute |where {$_.destinationprefix -eq '0.0.0.0/0'} |Get-NetIPInterface | Where {$_.ConnectionState -eq 'Connected'}) {
Write-Host "Route to internet established.." -ForegroundColor Red
Break
} else {
Start-Sleep -Seconds 2
Write-Host "." -NoNewline
}
}
Install-PackageProvider nuget -Force -Confirm:$false
Install-Script get-windowsautopilotinfo -Force -Confirm:$false
Install-Module microsoft.graph.intune -Force -Confirm:$false
Install-Module windowsautopilotintune -Force -Confirm:$false
Write-Host "Generating hash and uploading" -Foreground Green
& "C:\Program Files\WindowsPowerShell\Scripts\Get-WindowsAutoPilotInfo.ps1" -online -AppId xxxxx -TenantId yyy -AppSecret zzz
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | out-null
$result = [System.Windows.Forms.MessageBox]::Show('That should be it. Ready to shutdown?' , "Info" , 4)
if ($result -eq 'Yes') {
Stop-Computer -Force
}
Stop-Transcript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment