Hi guys,
I have little bit annoying problem with some services by me. In general by a reboot everything is fine, but the issues come when there are windows update, sometimes they caused services to hang, or took very long etc. So to fix it, I search, test some stuff and create a scheduled task to run 1 hours of the reboot to check for stopped services and run them.
# Start specific automatic start services not running
$server = "server1.domain.com"
$stoppedServices = (Get-WmiObject Win32_Service -ComputerName $server | Where-Object {$_.StartMode -eq 'Auto' -and $_.State -ne "Running"}).Name
foreach ($stoppedService in $stoppedServices) {
Write-Host -NoNewline "Starting Server/Service: "; Write-Host -ForegroundColor Green $server"/"$stoppedService
Get-Service -ComputerName $server -Name $stoppedService | Start-Service
}
or for example the Citrix services:
# Script to Manage the Citrix Services at an Citrix Session Host
Get-Service Citrix* -ErrorAction SilentlyContinue | Start-Service -ErrorAction SilentlyContinue
Get-Service CTX* -ErrorAction SilentlyContinue | Start-Service -ErrorAction SilentlyContinue
Get-Service BrokerAgent,CdfSvc,MRVCSvc,cpsvc,PvsVmAgent,ServicesManager,StackControlService -ErrorAction SilentlyContinue | Start-Service -ErrorAction SilentlyContinue
which is working fine. I use it as well manually in some cases instead of checking services.msc or server manager. My issue is with 3 different servers:
Wsus server where we have:
- Windows Internal Database with MSSQL$MICROSOFT##WID
- and WsusService
there, I have an issue with starting the DB and then start the services. Basically it should try to start the DB, wait, check again if the DB is running and after this restart WSUSservice if running or start if stopped.
TMMS server where I have: MSSQL$TMMS , TMMSManagementService, MSCSService which should start in this order. I have here some cases when I have to execute manually MSSQL$TMMS 1-2 times because I got Service start time out. And after this I should start the Management service and then MSCSservice (which sometimes starts although others are stopped, and I have to restart when others are up.
But the most annoying server is the Skype for Business server, where I have 3 SQL services and almost 20 Skype for Business services. The Front-End service for examples needs sometime 20 minutes to start while all other services are already running. As SQL I have MSSQL$LYNCLOCAL, MSSQL$RTC, MSSQL$RTCLOCAL.
So, any advice how to make all this start and wait and check again and then continue with others structure? I guess for the $ and # , I have to use ' instead of " , right?
Thanks in advance