add script
This commit is contained in:
22
Serveur Microsoft/service.ps1
Normal file
22
Serveur Microsoft/service.ps1
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Change service user name and password
|
||||
# www.sivarajan.com
|
||||
#
|
||||
clear
|
||||
$UserName = "CONNECT\Tomcat"
|
||||
$Password = "Password"
|
||||
$Service = "TomcatCPT16073" #Change service name with your service name
|
||||
$Cred = Get-Credential #Prompt you for user name and password
|
||||
Import-CSV C:\Scripts\input.csv | % {
|
||||
$ServerN = $_.ServerName
|
||||
$svcD=gwmi win32_service -computername $ServerN -filter "name='$service'" -Credential $cred
|
||||
$StopStatus = $svcD.StopService()
|
||||
If ($StopStatus.ReturnValue -eq "0") # validating status - http://msdn.microsoft.com/en-us/library/aa393673(v=vs.85).aspx
|
||||
{write-host "$ServerN -> Service Stopped Successfully"}
|
||||
$ChangeStatus = $svcD.change($null,$null,$null,$null,$null,$null,$UserName,$Password,$null,$null,$null)
|
||||
If ($ChangeStatus.ReturnValue -eq "0")
|
||||
{write-host "$ServerN -> Sucessfully Changed User Name"}
|
||||
$StartStatus = $svcD.StartService()
|
||||
If ($ChangeStatus.ReturnValue -eq "0")
|
||||
{write-host "$ServerN -> Service Started Successfully"}
|
||||
}
|
Reference in New Issue
Block a user