#
# Windows Server Inplace Upgrade  Server 2012 R2 => Server 2019
#
# zuerst Informationen sammeln
# Powershell als Admin starten:
  Get-ComputerInfo -Property WindowsBuildLabEx,WindowsEditionID | Out-File -FilePath c:\admin\computerinfo.txt
  systeminfo.exe | Out-File -FilePath c:\admin\systeminfo.txt
  ipconfig /all | Out-File -FilePath c:\admin\ipconfig.txt

# Automatische Updates abschalten:
  sconfig

# Namen ändern:
  sconfig

# runtefahren:
  shutdown /p

# Windows Media Player entfernen:
  dism /online /Disable-Feature /FeatureName:WindowsMediaPlayer /norestart

# Hilfe aktualisieren:
  Update-Help -force -erroraction silentlycontinue

### für Windows Server 2012 R2
# Sicherstellen, das Powershell 5.1 installiert ist mit der Powershell
  $PSVersionTable.PSVersion:
  (Get-Host).Version:
  Major  Minor  Build  Revision
  -----  -----  -----  --------
  5      1      19041  3031

# oder
  Get-Host

# installiere die Windows Defender GUI:
  Install-WindowsFeature -Name Windows-Defender-GUI

# SmartScreen einstellen:
  New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\System\ -Name EnableSmartScreen -Value 0 -PropertyType DWORD
  cd \windows\system32
  .\smartscreensettings.exe

# oder
  reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v SecurityHealth /d "%windir%\system32\SecurityHealthSystray.exe" /t REG_SZ /f

# setze Transport Layer Security (TLS) to 1.2
   [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12

# setze execution policy:
   Set-ExecutionPolicy RemoteSigned

# herunterladen von .NET Framework 4.5.2
  Invoke-WebRequest 'https://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe' -OutFile $env:USERPROFILE\Downloads\NDP452-KB2901907-x86-x64-AllOS-ENU.exe

# Neustart

# setze Transport Layer Security (TLS) to 1.2
   [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12

# setze execution policy:
   Set-ExecutionPolicy RemoteSigned

# herunterladen von WMF 5.1 / Powershell 5.1 ud installieren
  Invoke-WebRequest 'https://go.microsoft.com/fwlink/?linkid=839516' -OutFile $env:USERPROFILE\Downloads\Win8.1AndW2K12R2-KB3191564-x64.msu

# überprüfe:
  Get-Service winrm

# ggf starten:
  Start-Service winrm

# den automatischen Start einstellen:
  winrm set winrm/config/client/auth '@{Basic="True"}'

# setze Transport Layer Security (TLS) to 1.2
   [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12

# setze execution policy:
   Set-ExecutionPolicy RemoteSigned

# herunterladen von 'Windows Management Framework 5.1' / Powershell 5.1:
  https://www.microsoft.com/en-us/download/details.aspx?id=54616

# Neustart

# überprüfe die Version:
  (Get-Host).version

############################################################
MS: Installiere PowershellGet:

# start powershell als administrator

# setze Transport Layer Security (TLS) to 1.2
   [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12

# setze execution policy:
   Set-ExecutionPolicy RemoteSigned

# Installiere die letzte Version von PowerShellGet:
   Install-PackageProvider -Name NuGet -Force

# schließe das Powershell Fenster und start die Powershell neu

# Register PowerShell Gallery als ein vertrauenwürdigesrepository:
   Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
############################################################

# installiere das the Powershell Module 'PSWindowsUpdate'

# starte die powershell als admin !!!
# installiere das Modul PSWindows-Update:
   Install-Module -Name PSWindowsUpdate -Force

# frage die comands des Modules ab:
   Get-Command -Module PSWindowsUpdate

# frage die Version des Moduls ab:
   Get-Package -Name PSWindowsUpdate

# installiere eine neue Version des Moduls:
   Update-Module -Name PSWindowsUpdate

# suche nach neuen Updates:
   Get-WindowsUpdate -MicrosoftUpdate -Verbose

# Erhalte eine Liste der verfügbaren Updates:
   Get-WUlist

# Installiere die neuesten Updates mit Neutstart:
   Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot -Verbose

   Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -IgnoreReboot
############################################################
# das eigentliche Inplace Upgrade
# Serverrollen abfragen:
  $M = Get-Module -ListAvailable ServerManager
  Import-Module -ModuleInfo $M

Get-WindowsFeature | Where-Object {$_.InstallState -eq 'Installed'}
Get-WindowsFeature | Where-Object {$_. installstate -eq "installed"} | Format-List Name,Installstate | more

### Windows Server Inplace Upgrade für alle Versionen ###
# Rufe setup.exe vom Datenträger aus
############################################################

Links:
# Übersicht über Windows Server-Upgrades
https://learn.microsoft.com/de-de/windows-server/get-started/upgrade-overview

# Upgrade- und Konvertierungsoptionen für Windows Server
https://learn.microsoft.com/de-de/windows-server/get-started/upgrade-conversion-options