###################################################################### # @description: # # Used for running updates for Chocolatry apps and Windows Updates # # When the system is all-ready deployed # # # # @project: IMGSystTools # # @author: Bram Prieshof # ###################################################################### if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) { if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { $CommandLine = $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList " Set-ExecutionPolicy -Scope Process Unrestricted -Force; $CommandLine" Exit } } Write-Output "Checking Chocolatey package updates" choco upgrade -y all Write-Output " Chocolatey updates [OK]" Write-Output "Checking Windows updates" Import-Module PSWindowsUpdate Get-WUInstall -MicrosoftUpdate -AcceptAll -Install Write-Output " Windows updates [OK]" #Removing Created Shortcuts Remove-Item C:\Users\Public\Desktop\*.lnk