Powershell launch at specific times -


i building system restart computers patch purposes. of skeleton there , working, use workflows , functions allow me capture errors , reboot systems in number of ways in case of failures.

one thing not sure of how set timing. working on web interface people can schedule reboots, either dynamic (one-time) or regularly scheduled (monthly). server info , times boots stored in sql database.

the part missing how trigger reboots when scheduled. can think of allowing whole hour increments, , run script hourly checking see if servers in db have reboot time "matches" current time. work, inflexible.

can think of better way? sort of daemon?

for instance, user x has 300 servers assigned him. wants 200 rebooted @ 10 pm on each friday, , 50 once month on saturday @ 11 pm. there on dozen users rebooting 3000-4000 computers, multiple times monthly.

ok, let's have script takes date , time argument computers reboot based on specific date , time, or schedule, or whatever you're storing in sql db specifies how reboot things. sake of me not knowing sql well, we'll pretend functional (would require powershell community extensions snapin invoke-adocommand cmdlet):

[cmdletbinding()] param([string]$reboottime)  $constr = 'data source=sqlsrv01;database=reboottracking;integrated security=true;' $query = "select * table1 schedule = $reboottime" $data = invoke-adocommand -providername sqlclient -connectionstring $constr -commandtext $query $data | foreach{do things shutdown $_.servername} 

you said have things setup reboot servers didn't try there. have setup scheduledjob whenever server supposed rebooted:

register-scheduledjob –filepath \\srv01\scripts\rebootservers.ps1 –trigger @{frequency=weekly; at="10:00pm"; daysofweek="saturday"; interval=4} -argumentlist @{'reboottime'="day=saturday;weeks=4;time=22:00"} 

that's example, know, work accomplish needs. run once every 4 saturdays (about monthly). 1 scheduled task query sql server match string against field, , format way want make specific or general desired match. way 1 task reboot 200 servers, , reboot other 50 dependent on user's desires.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -