automatic_updates_v2/Start-Remote-task-updatescript.ps1
2024-12-20 22:15:56 +01:00

13 lines
532 B
PowerShell

#Load variables
. "C:\scripts\automatic-updates-static\Variables.ps1"
$password = Get-Content "c:\scripts\automatic-updates-static\localpassword.txt" | ConvertTo-SecureString
$username = $taskusername
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
$computernames = ($servers)
foreach($computername in $computernames)
{
Invoke-Command -ScriptBlock{Get-ScheduledTask -TaskName "Automatic-Updates-updatescript" | Start-ScheduledTask} -ComputerName $computername -Credential $credential
}