Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Remote PowerShell Defrag

$
0
0

I'm trying to setup remote defrag on some servers. I've checked a bunch of examples on the Google - but I don't quite understand the basic command to call to get defrag to run.

Can someone please tell me what I am missing from this code:

$Servers = "ServerName"

ForEach ($Server in $Servers)
{
    $Drive = Get-WmiObject -Class Win32_Volume -ComputerName $Server -Filter "DriveLetter = 'c:'"
    $Drive.Defrag()   
}

Thanks for any help.


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>