-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHWID-merger.ps1
38 lines (30 loc) · 1.26 KB
/
HWID-merger.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
# Prompt the user for the location of the HWID files
$HWIDFolder = Read-Host "Enter the location of the HWID folder on your USB-drive (example: D:\HWID)"
# Get all the HWID files in the folder
$hwidFiles = Get-ChildItem -Path $HWIDFolder -Filter *.csv -File
if ($hwidFiles.Count -eq 0) {
Write-Host "Error: No HWID-files found."
exit
}
# Check if the merged HWID file already exists
if ($true -eq (Test-Path -Path "$HWIDFolder\Autopilot-HWID.csv")){
Write-Host "Error: The Autopilot-HWID.csv file already exists."
exit
}
# Create a new CSV file to store the merged HWID data
$mergedHWIDFile = Join-Path -Path $HWIDFolder -ChildPath "Autopilot-HWID.csv"
$header = "Device Serial Number,Windows Product ID,Hardware Hash"
$header | Out-File -FilePath $mergedHWIDFile -Encoding utf8
# Loop through each HWID file
Write-Host "Reading HWID-files..."
foreach ($hwidFile in $hwidFiles) {
# Read the contents of the HWID file
$hwidData = Get-Content -Path $hwidFile.FullName
Write-Host "Writing HWID for $($hwidFile.Name)"
# Skip the header row
$hwidData = $hwidData | Select-Object -Skip 1
# Append the HWID data to the merged HWID file
$hwidData | Out-File -FilePath $mergedHWIDFile -Append -Encoding utf8
}
Write-Host "HWIDs combined!"
Pause