Hi Guys,
I’ve created the following script for like ~250 server
$servers = Import-csv “C:\temp\servers.csv”
ForEach ($server in $servers){
#createfolder
New-Item “\$($Server.Servername)\c$\Test1” -type directory
Start-Sleep 1
#copyfile
Copy-Item D:\Scripting\Files\bla1.txt -Destination \$($Server.Servername)\c$\Test1
}
This works. Now i would like to create a scedule task on the servers remotly.
When i do it directly to one server i use:
$Action = New-ScheduledTaskAction -Execute “Cmd”
$Trigger = New-ScheduledTaskTrigger -Once -At 17:00
Register-ScheduledTask Bodhi -Action $Action -Trigger $Trigger
This works. But i would like to do it on all the servers but with foreach i cannot fix it.
Some help please