##################
# Windows Update
##################

# query windows updates on cmd
   wmic qfe list
   wmic qfe list full
   wmic qfe list full /format:table
   wmic qfe list brief
   wmic qfe list full /format:htable > %USERPROFILE%\Desktop\WindowsUpdate_Report.html
   wmic qfe list full /format:htable > %USERPROFILE%\Desktop\WindowsUpdate_Report.html

# query updates with powershell
   get-wmiobject -class win32_quickfixengineering | Sort-Object InstalledOn -Descending

# query all updates
   Get-HotFix

# query security updates only
   Get-HotFix -Description Security* | Sort-Object InstalledOn -Descending

   Get-HotFix | Sort-Object InstalledOn -Descending
   (Get-HotFix | Sort-Object -Property InstalledOn)[-1]

# query Defender Updates
   get-eventlog -logname System | where message -like "Intelligence" | out-host -paging


# in the list of the commands you will see the commandlets of the repository:
   get-command -module *update*

# to see the list of available updates, type
   get-windowsupdatelog

# ensure that the latest 'Servicing Stack Updates' (SSUs) are installed:
Microsoft Catalog, SSUs

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

# start powershell as administrator

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

# set execution policy
   Set-ExecutionPolicy RemoteSigned

# Install the latest version of PowerShellGet
   Install-PackageProvider -Name NuGet -Force

# close powershell window and start new powershell

# Register PowerShell Gallery as a trusted repository
   Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
############################################################

# install the powershell module 'PSWindowsUpdate'

# run powershell as admin !!!
   Install-Module -Name PSWindowsUpdate -Force

# get comands of the module
   Get-Command -Module PSWindowsUpdate

# get version of the module
   Get-Package -Name PSWindowsUpdate

# get a new version of the module
   Update-Module -Name PSWindowsUpdate

# search for new updates
   Get-WindowsUpdate -MicrosoftUpdate -Verbose

# get a list of available updates
   Get-WUlist

# install latest updates with reboot
   Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot


# install the 'Security Intelligence Update':
   Get-WindowsUpdate -Install -kbarticle "KB2267602"

# information about
   Get-Command -Module WindowsUpdateProvider

# Links
   https://www.powershellgallery.com/packages/PSWindowsUpdate/2.0.0.4
   https://www.parallels.com/blogs/ras/powershell-windows-update/
   https://www.security-insider.de/windows-updates-mit-powershell-steuern-a-1084970/