31 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PowerShell
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PowerShell
		
	
	
	
	
	
$AvailableUpdates = $null;
 | 
						|
$AvailableUpdates = get-wulist;
 | 
						|
New-Item -Name updates.csv -ItemType File
 | 
						|
If ($null -ne $AvailableUpdates)
 | 
						|
{
 | 
						|
#$AvailableUpdates;
 | 
						|
set-location C:\scripts\automatic-updates\
 | 
						|
#Remove existing task that will open this script
 | 
						|
C:\scripts\automatic-updates\run_from_script\Delete-task.ps1
 | 
						|
#Create task to open Check-updates.ps1 after reboot
 | 
						|
C:\scripts\automatic-updates\run_from_script\Create-task-reboot.ps1
 | 
						|
#Create or append csv file with available updates
 | 
						|
C:\scripts\automatic-updates\run_from_script\Check-Updates-csv.ps1
 | 
						|
#Install available updates and reboot
 | 
						|
C:\scripts\automatic-updates\run_from_script\Install-updates.ps1
 | 
						|
}
 | 
						|
Else
 | 
						|
{
 | 
						|
Write-Host "No updates found";
 | 
						|
#Remove existing task that will open this script
 | 
						|
C:\scripts\automatic-updates\run_from_script\Delete-task.ps1
 | 
						|
#Send mail that there are no updates available
 | 
						|
#C:\scripts\automatic-updates\run_from_script\No-updates.ps1 #(If no updates are found this will be send from send-mail-attachment.ps1)
 | 
						|
#Send mail with csv file with all updates installed
 | 
						|
C:\scripts\automatic-updates\run_from_script\Send-mail-attachment.ps1
 | 
						|
#delete csv file
 | 
						|
set-location C:\scripts\automatic-updates\
 | 
						|
Remove-Item updates.csv
 | 
						|
#start updates other servers
 | 
						|
C:\scripts\automatic-updates\run_from_script\Start-Remote-task.ps1
 | 
						|
} |