Update
This commit is contained in:
@@ -20,10 +20,28 @@ function CheckOfficeInstall {
|
|||||||
InstallOffice
|
InstallOffice
|
||||||
}
|
}
|
||||||
Write-Host "Activating Windows and Office..."
|
Write-Host "Activating Windows and Office..."
|
||||||
|
$status = CheckActivation
|
||||||
|
|
||||||
ActivateWindowsOffice
|
ActivateWindowsOffice
|
||||||
Write-Host "Windows and Office activation complete!"
|
Write-Host "Windows and Office activation complete!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function CheckActivation {
|
||||||
|
$osLicense = Get-CimInstance -ClassName SoftwareLicensingProduct | Where-Object { $_.Description -match "Windows" }
|
||||||
|
$officeLicense = Get-CimInstance -ClassName SoftwareLicensingProduct | Where-Object { $_.Description -match "Office" }
|
||||||
|
$windows = $osLicense.Description
|
||||||
|
$office = $officeLicense.Description
|
||||||
|
|
||||||
|
# if both activated return true
|
||||||
|
if ($osLicense.LicenseStatus -eq 1 -and $officeLicense.LicenseStatus -eq 1) {
|
||||||
|
Write-Host "Windows and Office are activated."
|
||||||
|
return $true
|
||||||
|
} else {
|
||||||
|
Write-Host "Windows and Office are not activated."
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function InstallOffice {
|
function InstallOffice {
|
||||||
DownloadFiles -Type "Office"
|
DownloadFiles -Type "Office"
|
||||||
$imagePath = Join-Path $tmpPath "O365ProPlusRetail.img"
|
$imagePath = Join-Path $tmpPath "O365ProPlusRetail.img"
|
||||||
|
|||||||
26
setupReg.ps1
26
setupReg.ps1
@@ -87,14 +87,26 @@ function SetupEleveReg {
|
|||||||
}
|
}
|
||||||
Write-Host "Added registry entries"
|
Write-Host "Added registry entries"
|
||||||
Write-Host "Unloading registry HIVE"
|
Write-Host "Unloading registry HIVE"
|
||||||
Start-Sleep -s 5
|
$retryCount = 0
|
||||||
Write-Host "REG UNLOAD HKEY_USERS\$UserSID"
|
$retryLimit = 5
|
||||||
$res = REG UNLOAD HKEY_USERS\$UserSID
|
$success = $false
|
||||||
if ($res -ne 0) {
|
|
||||||
Write-Host "Failed to unload $username's HKU registry hive."
|
while (-not $success -and $retryCount -lt $retryLimit) {
|
||||||
|
Start-Sleep -s 5
|
||||||
|
Write-Host "REG UNLOAD HKEY_USERS\$UserSID (attempt $($retryCount + 1))"
|
||||||
|
$res = REG UNLOAD HKEY_USERS\$UserSID
|
||||||
|
if ($res -ne 0) {
|
||||||
|
Write-Host "Failed to unload $username's HKU registry hive. Retrying in 5 seconds..."
|
||||||
|
$retryCount++
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "Unloaded $username's HKU registry hive."
|
||||||
|
$success = $true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
Write-Host "Unloaded $username's HKU registry hive."
|
if (-not $success) {
|
||||||
|
Write-Host "Failed to unload $username's HKU registry hive after $retryLimit attempts."
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Unable to get the user's HKU registry."
|
Write-Host "Unable to get the user's HKU registry."
|
||||||
|
|||||||
Reference in New Issue
Block a user