We have a newprint serverandwant to runa scriptonall clientsvia GPO.Itshould beall connections to theoldprint serverdeleted.
$oldPrinterName = "\\Server01\"
$comNetwork = New-Object -ComObject "Wscript.Network"
$printer = gwmi -Class Win32_Printer | ?{$_.Network -eq $true -and $_.ServerName -eq "\\$($oldprinterName.Split("\")[2])" -and $_.ShareName -eq $oldprinterName.Split("\")[3]}
if ($printer) {
$printer | %{$comNetwork.RemovePrinterConnection($_.Name)}
}else{
exit
}
Is this the rightway?