Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Helper file to spin up various required services
# Helper method
function StartService($ServiceName) {
$arrService = Get-Service -Name $ServiceName
while ($arrService.Status -ne 'Running')
{
Start-Service $ServiceName
write-host $arrService.status
write-host 'Service starting'
Start-Sleep -seconds 5
$arrService.Refresh()
if ($arrService.Status -eq 'Running')
{
Write-Host "Service '$ServiceName' is now Running"
}
}
}
# Services to ensure is started
StartService('MSDTC')
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.