Added auto Prepend for systemname and removed enableing/disableing WU

Now prepending 'PC' to the given input (assetID), since windows refuses system name only consisting of numbers.
Removed setting status of Windows updates services since this did not work,
this feature was meant to pause WU until the system was activated, to prevent the network form being overloaded
This commit is contained in:
2022-06-10 14:12:15 +02:00
parent 0169acc9b3
commit a3da939025

View File

@@ -16,16 +16,13 @@ if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdent
}
}
#Disable Windows updates service
Set-Service -Name "wuauserv" -Status Stopped -StartupType Disabled
Write-Output "Checking activation status..."
$ta = Get-CimInstance -ClassName SoftwareLicensingProduct -Filter "PartialProductKey IS NOT NULL" | Where-Object -Property Name -Like "Windows*"
if ($ta.LicenseStatus -eq 1) {Write-Output "Activation [OK]"} else {Write-Output "Activation [Error, Opening settings]";Start-Process "ms-settings:activation"; pause }
Write-Output "Getting System name"
$sysid = Read-Host -Prompt 'Please enter asset ID:'
Rename-Computer -NewName $sysid
Rename-Computer -NewName "PC$sysid"
Write-Output "System name [OK]"
#Chocolaty software updates
@@ -38,9 +35,6 @@ if ( $confirmSupdates -eq 'y'){
$confirmWupdates = Read-Host "Run Windows updates? (y/n)"
if ( $confirmWupdates -eq 'y'){
#Enable Windows updates service
Set-Service -Name "wuauserv" -Status Stopped -StartupType Manual
Write-Output "Checking Windows updates"
Import-Module PSWindowsUpdate
Get-WUInstall -MicrosoftUpdate -AcceptAll -IgnoreReboot -IgnoreRebootRequired -Install