This topic contains 5 replies, has 3 voices, and was last updated by
August 3, 2017 at 8:26 am #76536
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.
August 3, 2017 at 9:01 am #76543ParticipantPoints: 64Rank: Member
The bottom script does exactly what you require (I think ) 🙂
August 3, 2017 at 9:08 am #76545
Thanks simon but that not what i am looking for because i have already deployment other scripts on my severs. There has to be a way to do it like i posted above?
August 3, 2017 at 9:12 am #76548ParticipantPoints: 64Rank: Member
Are your servers in the same OU ?
August 3, 2017 at 9:19 am #76552
Yes they are, but i would like to manage which servers are about to restart so not all servers in the OU
August 3, 2017 at 11:26 am #76555ParticipantPoints: 0Rank: Member
Enter-PSSessionfor interactive use only
you should use
look at example 9 for Invoke-Command
The topic ‘Scheduldtask script question’ is closed to new replies.