This topic contains 4 replies, has 3 voices, and was last updated by
June 3, 2014 at 8:11 am #15850
ok, I have been in the Social Forums with this question, and they tell me it cant be done.
If I had my servers in Core mode, versus the GUI, how would I change this schedule from weekly to daily? (see attached screenshots)
and better yet, if I had 1000 servers how would I check to see what they were set for?
(Background....OpsMan2012 R2 is telling me my drives need optimized, I know how to optimize them, but would rather programaticaly change the schedule to daily on all my servers, and then deal with the outlayers that cant stay with-in the range.)
June 3, 2014 at 8:18 am #15853KeymasterPoints: 1,811Rank: Community Hero
So does this schedule live in Scheduled Tasks or entirely in SCOM?
The Social link included a post from "Anna" about scheduling the command in Scheduled Tasks. Windows 8 and Windows Server 2012 certainly contain commands that would let you set up that schedule on multiple computers, provided you can communicate with them via Remoting. On older machines, you could certainly do it via WMI instead if you preferred.
That's what the Invoke-Command reference was. That would let you run Anna's commands on one or more remote computers. It would require them to have Remoting enabled; almost any "do this on hundreds of remote computers" will involve Remoting, since it's the technology PowerShell uses to do that.
June 3, 2014 at 8:47 am #15855
Ok, this lives inside Scheduled Tasks, under task scheduler library ->Windows -> Defrag.
I guess I figured it was running the PowerShell command and not %windir%\system32\defrag.exe -c -h -o -$
I can push the script via PowerShell to run each night, and might do that as part of my build process, I guess I drank the Kool-Aid of if you can set it in the GUI, it really is just running a PowerShell command behind the scenes, which in most cases, I have found to be true, but some things are still running legacy technology.
But my Standardization Side of me (read as OCD), does not like the GUI Saying weekly, but I am running it Nightly. I will have to go back and change those as I run across them.
once again, thank you for your quick response.
June 3, 2014 at 9:47 am #15860MemberPoints: 0Rank: Member
In Server 2012 / Windows 8 or later, there's a ScheduledTasks module with PowerShell cmdlets that can allow you to get and set that information (Get-ScheduledTask, Get-ScheduledTaskInfo, etc). If you need to do this on older operating systems, you'll have to work with schtasks.exe instead.
schtasks.exe /Query /TN "Microsoft\Windows\Defrag\ScheduledDefrag" /XML
This output can be cast to the [xml] type in PowerShell to work with it fairly easily. See http://blogs.technet.com/b/heyscriptingguy/archive/2013/12/14/working-with-task-scheduler-xml.aspx for some good examples of this.
The content of this task seems to have changed quite a bit between Server 2008 R2 and Server 2012, so you might need to use different commands to modify (or more likely, delete and recreate) the task depending on the OS.
June 3, 2014 at 2:14 pm #15870
Thank You, David.
This helps a lot, At least I can pull this from all my machines and figure out which ones need to be changed.
between you and Anna's script, I should be able to knock out this inconstancy pretty quickly.
The topic ‘Optimze-Volume Schedule.(storage Mangement)’ is closed to new replies.