Guys, you helped me so much this week. Last question to complete everything
I’ve got on every server (±150) my reboot schedule task. but every month i would like to restart the servers after patching.
I created the following:
$servers = Get-Content C:\temp\servers.txt
$DateTime = Read-Host “Date and Time (MM/DD/YY)”
$User = Read-host “Admin username”
$Password = Read-Host “Enter Password” -AsSecureString
foreach ($server in $servers)
$Time = New-ScheduledTaskTrigger -At $DateTime -Once
Set-ScheduledTask -TaskName “Rebootserver” -Trigger $Time -User nbdbiblion$user -Password $password
I works, but i creates only locally on my computer but i would like to create it on the servers. I think inovke-command wil not work because of the variables that are needed.