Skip to content

Commit

Permalink
d
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdwegen authored Dec 3, 2023
1 parent 6b2a911 commit 91a85a4
Showing 1 changed file with 47 additions and 5 deletions.
52 changes: 47 additions & 5 deletions scripts/postoobe.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,51 @@
Install-Module -Name PSWindowsUpdate -Force -Confirm:$false
Get-WindowsUpdate -Install -AcceptAll -AutoReboot -Verbose -Confirm:$false
pause
try {
# Change execution policy
if ((Get-ExecutionPolicy) -ne "Unrestricted") {
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted -Force -Confirm:$false
Write-Host "Executionpolicy has been changed to unrestricted for this process" -ForegroundColor Green
}

# Install PackageProvider NuGet
try {
if (!(Get-PackageProvider | Where-Object { $_.Name -eq "NuGet" })) {
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Confirm:$FALSE | Out-Null
}
} catch {
throw "Failed to find/install NuGet: $($_.Exception.Message)"
}

# Check & Install requisite modules
$installedModules = Get-InstalledModule
Write-Host "Checking modules..."
@('PSWindowsUpdate') | ForEach-Object {
try {
if ($installedModules.Name -notcontains $($_)) {
Install-Module -Name $($_) -Force -Confirm:$FALSE
Write-Host "Module $($_) has been installed" -ForegroundColor Green
} else {
Write-Host "Module $($_) has been found" -ForegroundColor Green
}
} catch {
throw "Failed to install/find module $($_): $($_.Exception.Message)"
}
}
} catch {
throw "$($_.Exception.Message)"
}

# try {
# {(Get-WmiObject Win32_bios).SerialNumber | Rename-Computer}
# $serialNumber = (Get-WmiObject Win32_bios).SerialNumber
# if ($env:COMPUTERNAME -ne $serialNumber) {
# $serialNumber | Rename-Computer
# }
# } catch {
# throw "$($_.Exception.Message)"
# }

# }
try {
Write-Host "ATTEMPTING TO INSTALL ALL WINDOWS UPDATES" -ForegroundColor DarkYellow
Write-Host "THIS MAY TAKE A WHILE..." -ForegroundColor DarkYellow
Get-WindowsUpdate -Install -AcceptAll -AutoReboot -RecurseCycle -Verbose -Confirm:$false
} catch {
throw "$($_.Exception.Message)"
}

0 comments on commit 91a85a4

Please sign in to comment.