brad
(Br@d)
1
Description
This simple little powershell script allows to interactively start or stop a servies plus change its startup type if desired on a local or remote computer. You can also expanded apon this to run on a list of computers. It is very straight forward to run and documented line by line
Source Code
# SetService.ps1 by Brad Call of Internal IT Ltd. www.internalit.ca @internal_it
# This will allow you to Start/Stop, Enable/Disable Services on 1 or many remote computers
# You should have PowerShell V2 installed to run correctly plus meet all remote powershell requirements
# Sets the base computer search name
$COMP= Read-Host "Enter Computer Name"
# Sets the service name to edit, name can be found with get-service
$SRV= Read-Host "Enter Name of Service"
# Sets what action is to be taken with the stated service
$ACTION= Read-Host "Enter 'STOPPED' to Stop the Service or 'RUNNING' to Start it"
#
$CHANGESTARTUP= Read-Host "Does the Startup Type Need to be Changed? Y/N"
# Finds if the Startup type of services is to be changed
If ($CHANGESTARTUP -eq 'Y')
{
# Sets option for startup type
$STARTUPTYPE= Read-Host "Enter 'DISABLED', 'MANUAL' or 'AUTOMATIC'"
# Starts or stops the service and sets the statup type
Set-Service -ComputerName $COMP -name $srv -status $ACTION -StartupType $STARTUPTYPE
}
# Alternate action if the startup type is not being changed
Else
{
# Starts or stops the service
Set-Service -ComputerName $COMP -name $srv -status $ACTION
}
2 Spice ups
kfberns
(kfberns)
2
Works as advertised - Thanks, this is exactly what I was looking for.