-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathImport-AutoPilotHash.ps1
55 lines (39 loc) · 1.76 KB
/
Import-AutoPilotHash.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# This script is expected to run while connected to the internet
$isOnline = Invoke-WebRequest -UseBasicParsing -Uri "https://graph.microsoft.com"
if (!$isOnline) {
Write-Output "This device appear to NOT be Internet Connected."
Read-Host "Press Enter to Exit "
exit
}
Write-Host "Installing NuGet"
Install-PackageProvider -Name NuGet -Force
Write-Host "Installing Azure AD Module"
Install-Module -Name AzureAD -Force
Write-Host "Installing Microsoft Graph Intune Module"
Install-Module -Name Microsoft.Graph.Intune -Force
Write-Host "Installing AutoPilot Module"
Install-Module -Name WindowsAutoPilotIntune -Force
Write-Host "Fetching AutoPilot Script"
Save-Script -Name Get-WindowsAutoPilotInfo -Path ./
Write-Output "`n`nLog in to Azure AD..."
Connect-MSGraph
$CSVFile = "$(get-date -Format FileDateTimeUniversal).csv"
./Get-WindowsAutoPilotInfo.ps1 -OutputFile $CSVFile
# Read CSV and process each device
$devices = Import-CSV $CSVFile
$OrderID = $null
$OrderID = Read-Host -Prompt "Enter the Order ID / Deployment Group (or leave blank for none)"
if ($OrderID) {
foreach ($device in $devices) {
Add-AutoPilotImportedDevice -serialNumber $device.'Device Serial Number' -hardwareIdentifier $device.'Hardware Hash' -orderIdentifier $OrderID
Write-Output "Imported Device $($device.'Device Serial Number')"
}
Write-Host "OrderID: '$OrderID'"
} else {
foreach ($device in $devices) {
Add-AutoPilotImportedDevice -serialNumber $device.'Device Serial Number' -hardwareIdentifier $device.'Hardware Hash'
Write-Output "Imported Device $($device.'Device Serial Number')"
}
}
Write-Output "It will take several minutes for the device to appear in the Intune portal before a Profile will be assigned."
#Remove-Item -Path $CSVFile