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.