Sysprep Windows (incl. Policies): Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) |
Admin (Diskussion | Beiträge) K |
||
(Eine dazwischenliegende Version des gleichen Benutzers werden nicht angezeigt) | |||
Zeile 6: | Zeile 6: | ||
[Parameter(Mandatory = $true)] | [Parameter(Mandatory = $true)] | ||
− | [pscredential]$ | + | [pscredential]$LocalAdminCreds |
) | ) | ||
− | Invoke-Command -ComputerName $ComputerName -Credential $ | + | Invoke-Command -ComputerName $ComputerName -Credential $LocalAdminCreds -ScriptBlock { |
#Reset Wsus Settings | #Reset Wsus Settings | ||
Write-Output "[$(Get-Date -Format HH:mm:ss)][$USING:ComputerName] Resetting Wsus configuration" | Write-Output "[$(Get-Date -Format HH:mm:ss)][$USING:ComputerName] Resetting Wsus configuration" | ||
Zeile 37: | Zeile 37: | ||
Write-Output "[$(Get-Date -Format HH:mm:ss)][$USING:ComputerName] Sysprep has been triggered, after this the Computer will shutdown" | Write-Output "[$(Get-Date -Format HH:mm:ss)][$USING:ComputerName] Sysprep has been triggered, after this the Computer will shutdown" | ||
Start-Sleep -Seconds 1 | Start-Sleep -Seconds 1 | ||
− | + | Invoke-WMIMethod -Class Win32_Process -Name Create -ArgumentList "cmd /c c:\windows\system32\sysprep\sysprep.exe /generalize /oobe /mode:vm /shutdown /quiet" | Out-Null | |
Start-Sleep -Seconds 5 | Start-Sleep -Seconds 5 | ||
} | } |
Aktuelle Version vom 25. Januar 2022, 15:14 Uhr
Function Reset-WindowsForImage { param ( [Parameter(Mandatory = $true)] [string]$ComputerName, [Parameter(Mandatory = $true)] [pscredential]$LocalAdminCreds ) Invoke-Command -ComputerName $ComputerName -Credential $LocalAdminCreds -ScriptBlock { #Reset Wsus Settings Write-Output "[$(Get-Date -Format HH:mm:ss)][$USING:ComputerName] Resetting Wsus configuration" Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\" -Name * | Out-Null Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\" -Name * | Out-Null $regkeyPathAU = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" | Out-Null New-ItemProperty -path $regkeyPathAU -Name "AUOptions" -value 3 -PropertyType "DWord" | Out-Null New-ItemProperty -path $regkeyPathAU -Name "NoAutoUpdate" -value 1 -PropertyType "DWord" | Out-Null #Reset local Update Database Write-Output "[$(Get-Date -Format HH:mm:ss)][$USING:ComputerName] Resetting local Wsus Database" Stop-Service -Name "BITS" Stop-Service -Name "wuauserv" $softwareDistributionPath = "$env:windir\SoftwareDistribution" Remove-Item -path $softwareDistributionPath -recurse -Force #Reset Network settings Write-Output "[$(Get-Date -Format HH:mm:ss)][$USING:ComputerName] Resetting Network adapter settings" Get-DnsClientServerAddress | Where-Object {$_.InterfaceAlias -eq "Ethernet"} | Set-DnsClientServerAddress -ResetServerAddresses Get-DnsClient | Set-DnsClient -ResetConnectionSpecificSuffix #Reset all local Security Policy settings (for example Password complexity) Write-Output "[$(Get-Date -Format HH:mm:ss)][$USING:ComputerName] Resetting all local Security Policy settings" SecEdit.exe /configure /cfg C:\Windows\inf\defltbase.inf /db defltbase.sdb /verbose #Sysprepping the System Write-Output "[$(Get-Date -Format HH:mm:ss)][$USING:ComputerName] Sysprep has been triggered, after this the Computer will shutdown" Start-Sleep -Seconds 1 Invoke-WMIMethod -Class Win32_Process -Name Create -ArgumentList "cmd /c c:\windows\system32\sysprep\sysprep.exe /generalize /oobe /mode:vm /shutdown /quiet" | Out-Null Start-Sleep -Seconds 5 } }