ACTION : Stop & Disable une service sur un server distant
Le credential sont donnés via la variable $cred
$cred = get-credential
RETURN : Retourne un hashtable avec le resultat.
In this script I want to disable the service "V-Locity" on the machine name list in c:\x.txt :
Cat c:\x.txt | % $disabled = (Get-WmiObject win32_service -ComputerName $_ -Credential $cred | ? { $_.name -match "V-locity"}).InvokeMethod("ChangeStartMode","Disabled") $stop = (Get-WmiObject win32_service -ComputerName $_ -Credential $cred | ? { $_.name -match "V-locity"}).stopservice() $object = new-object psobject -property @{ Name = $_ Disabled = $disabled stop = $stop } $object }
Aucun commentaire:
Enregistrer un commentaire