talksr Posted April 10, 2017 Posted April 10, 2017 Hi there, I am looking for a little help. I have around 35 stations I would like to remote defrag. There is a useful remote powershell command which allows you to defrag a remote system: Get-WmiObject win32_volume -filter "driveletter='c:'" -ComputerName computer-name-here | Invoke-WmiMethod -Name Defrag This works quite well, but could take a while to do as you would need to manually enter in the computer name each time. Does anyone have any ideas on how I could make this quicker? Also, would be good if there is a way to see progress or get confirmation that the command went through - I am assuming it is working as I didn't get a red error text reply after hitting return. Thanks in advance.
benjie Posted April 10, 2017 Posted April 10, 2017 (edited) Hopefully this will help. Doing this from my phone so can't confirm syntax and commands. Put computer names in an array $computers = "computer1", "computer2", "computer3" Foreach $a in $computers { get-wmiobject .....} Obviously put all computer names in computers array and complete the command in { } and where you have computer name reference $a Hopefully this will help. If not have a Google for "foreach powershell" Don't know if you check if it is complete. Is there a wmi query for this??? Edited April 10, 2017 by benjie 1
markwilfan Posted April 10, 2017 Posted April 10, 2017 Why are you wanting to defrag them? Are you using Windows 98? 1
Arthur Posted April 10, 2017 Posted April 10, 2017 Does Win 7+ do this during maintenance? Yes. www.thewindowsclub.com/disk-defragmenter-windows The Disk Defragmenter runs as a low priority task in the background without affecting the performance of the computer. It runs only when the machine is idle. It uses the Task Scheduler to automatically keep the hard disk defragmented. This automated defragmentation does not affect the performance of the Windows. 1
Fazza Posted April 13, 2017 Posted April 13, 2017 Upgrade your OS to Windows 7, 8, 8.1, 8.1u1 or 10 as its automated in them.
ITGURU Posted April 13, 2017 Posted April 13, 2017 create a folder and put psexec inside. then create a batch file with the below,and double click to run it. Export all pc names from AD open in excel then add the extra bits to it to get the full line. PsExec -s -d \\pcname1 c:\windows\system32\defrag.exe c: -f PsExec -s -d \\pcname2 c:\windows\system32\defrag.exe c: -f PsExec -s -d \\pcname3 c:\windows\system32\defrag.exe c: -f etc etc etc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now