Created
September 30, 2018 06:29
-
-
Save SQLDBAWithABeard/7a8866d7859759b15b833106d2c420a2 to your computer and use it in GitHub Desktop.
Setting services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$vms.ForEach{ | |
Write-Output "Looking at VM $psitem" | |
# Get the Engine Services | |
$EngineServices = Get-DbaService -ComputerName $psitem -Type Engine | |
# Loop through the engine services | |
$EngineServices.ForEach{ | |
$ComputerName = $psitem.ComputerName | |
$Name = $Psitem.ServiceName | |
$InstanceName = $psitem.InstanceName | |
Write-Output "Service $Name StartMode on $ComputerName is $($Psitem.startmode)" | |
# Set Start Mode to Manual | |
Set-Service -ComputerName $ComputerName -Name $Name -StartupType Manual | |
#Restart-Service | |
Get-Service -ComputerName $ComputerName -Name $Name| Restart-DbaService | |
$Service = Get-DbaService -ComputerName $ComputerName -InstanceName $InstanceName -Type Engine | |
Write-Output "Service $Name StartMode on $ComputerName is $($Service.startmode)" | |
} | |
} |
Author
SQLDBAWithABeard
commented
Sep 30, 2018
$vms.ForEach{
$VM = $Psitem
Write-Output "Looking at VM $VM"
Get the Engine Services
$EngineServices = Get-Service -ComputerName $VM -Name MSSQLSERVER
Loop through the engine services
$EngineServices.ForEach{
$Name = $Psitem.Name
Write-Output "Service $Name StartMode on $ComputerName is $($Psitem.starttype)"
# Set Start Mode to Manual
Set-Service -ComputerName $VM -Name $Name -StartupType Manual
#Stop-Service
Get-Service -ComputerName $VM -Name $Name| Stop-Service
$Service = Get-Service -ComputerName $VM -Name MSSQLSERVER
Write-Output "Service $Name StartMode on $ComputerName is $($Service.starttype)"
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment