#Only run this one time to setup server for automatic updates New-Item -ItemType File -Path C:\Scripts\automatic-updates-static\variables.ps1 -Force Copy-Item C:\Scripts\automatic-updates\variables.ps1 C:\Scripts\automatic-updates-static\variables.ps1 New-Item -ItemType File -Path C:\Scripts\automatic-updates-static\updatescript.ps1 -Force Copy-Item C:\Scripts\automatic-updates\updatescript.ps1 C:\Scripts\automatic-updates-static\updatescript.ps1 New-Item -ItemType File -Path C:\Scripts\automatic-updates-static\Start-Remote-task-updatescript.ps1.ps1 -Force Copy-Item C:\Scripts\automatic-updates\Start-Remote-task-updatescript.ps1 C:\Scripts\automatic-updates-static\Start-Remote-task-updatescript.ps1 #Install required modules C:\scripts\automatic-updates\Run_scripts_onetime\install_module.ps1 #Create encrypted password file to be able to send mail Write-Host "Enter password for mail" -ForegroundColor Yellow Write-Host "Press a key to continue" -ForegroundColor Yellow [void][System.Console]::ReadKey($true) C:\scripts\automatic-updates\Run_scripts_onetime\email-password.ps1 #Create encrypted password file to create and run tasks Write-Host "Enter username and password of service account" -ForegroundColor Yellow Write-Host "Press a key to continue" -ForegroundColor Yellow [void][System.Console]::ReadKey($true) C:\scripts\automatic-updates\Run_scripts_onetime\localpassword.ps1 #> $shell = new-object -comobject "WScript.Shell" $result = $shell.popup("Are you running this script from primary domain controller?",0,"Question",4+32) if ($result -eq "6") { Write-Host @" You are running this from the domain controller. You have to create a task manualy on the server. Create a task manual with the name "Automatic-Updates" Use as trigger montly on first Thursday. As Actions Start a program. powershell.exe with arguments "-NoProfile -File C:\Scripts\automatic-updates\Automatic-updates.ps1". Use the service account and choose to run whether user is logged on or not. Press a key to continue "@ -ForegroundColor Yellow [void][System.Console]::ReadKey($true) } else { Write-Host "We will create a task that will not start automaticaly. This will be run from the domain controller." -ForegroundColor Yellow enable-WUremoting C:\scripts\automatic-updates\Run_scripts_onetime\Create-task-remote.ps1 C:\scripts\automatic-updates\Run_scripts_onetime\Create-task-updatescript.ps1 } Write-Host "The variables.ps1 is copied to c:\scripts\automatic-updates-static. Please edit this file" -ForegroundColor Yellow