Sunday, 22 December 2013

How to stop or start a specifc service on local as well on remote systems

This time I am posting Powershell Script on How to stop or start  a specifc service on local as well on remote systems

 

Get-Service -Name w32time
 
Output
 
PS C:\Users\administrator> Get-Service -Name w32time
Status   Name               DisplayName                          
------   ----               -----------                          
Running  w32time            Windows Time       

 
For stopping
 
Get-Service -Name w32time | Stop-Service
 
checking for Status

 PS C:\Users\administrator> Get-Service -Name w32time

Status   Name               DisplayName                          
------   ----               -----------                          
Stopped  w32time            Windows Time
                         


For Bulk of servers This time we are doing stopping as well Disabling the service




$computers = Get-Content C:\servers.txt

ForEach ($computer in $computers)

{

  
      Stop-Service -InputObject $(Get-Service -Computer $computer -Name w32time);
 Set-Service  -StartupType "Disabled" -InputObject $(Get-Service -Computer $computer -Name w32time);

   
}



 

No comments:

Post a Comment

Powershell function to get theremote server IP details,Subnetmask,Gateway,DHCP Enabled status,DNS Servers,Wins and Macaddress

#Powershell function to get theremote server IP details,Subnetmask,Gateway,DHCP Enabled status,DNS Servers,Wins and Macaddress # use...