-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall-EmbeddedProductKey.ps1
More file actions
26 lines (22 loc) · 1.08 KB
/
Install-EmbeddedProductKey.ps1
File metadata and controls
26 lines (22 loc) · 1.08 KB
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
$Global:Transcript = "$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Install-EmbeddedProductKey.log"
Start-Transcript -Path (Join-Path "$env:ProgramData\Microsoft\IntuneManagementExtension\Logs\OSD\" $Global:Transcript) -ErrorAction Ignore
$Model = (Get-WmiObject -Class Win32_ComputerSystem).Model
if ($Model -match 'Virtual|Vmware') {
Write-Host -ForegroundColor Green "Virtual Machine Detected skipping..."
}
Else{
Write-Host -ForegroundColor Green "Get embedded product key"
$Key = (Get-WmiObject SoftwareLicensingService).OA3xOriginalProductKey
If ($Key) {
Write-Host -ForegroundColor Green "Installing embedded product key"
Invoke-Command -ScriptBlock {& 'cscript.exe' "$env:windir\system32\slmgr.vbs" '/ipk' "$($Key)"}
Start-Sleep -Seconds 5
Write-Host -ForegroundColor Green "Activating embedded product key"
Invoke-Command -ScriptBlock {& 'cscript.exe' "$env:windir\system32\slmgr.vbs" '/ato'}
Start-Sleep -Seconds 5
}
Else {
Write-Host -ForegroundColor Red 'No embedded product key found.'
}
}
Stop-Transcript