SkypeToolPack.psm1
function Get-CSPoolServices { # Check if all services are running on all servers in a pool. # If any services are detected as not running, ask the user if they want to start the service. # Alternatively, use a switch to define if the function shall automatically start any services that aren't currently running. # TODO: Switch to always correct services and a switch to not ask param ( [Parameter(Position = 0, Mandatory = $true)] [string]$PoolFQDN, [string]$ReportPath ) $servers = Get-CsPool -identity $PoolFQDN Write-Output "Running Get-CsWindowsService on all computers in the pool" foreach ($server in $servers.computers) { Write-Output $server $result = Get-CsWindowsService -ComputerName $server Write-Output $result if ($ReportPath) { $result | Format-Table -AutoSize | Out-File -FilePath $ReportPath -Append } if ($result.status -contains "stopped") { Write-Warning "A service is not running. This might result in a bad user experience." Write-Output "Would you like to start the service?" do { $serviceStart = Read-Host "(Y)es or (N)o" if ($serviceStart.ToLower() -eq "y") { Start-CSWindowsService -ComputerName $server if ($ReportPath) { $serviceStartReport = "Stopped services started by user." Out-File -FilePath $ReportPath -InputObject $serviceStartReport -Append } break } } while ($serviceStart.ToLower() -notlike "n") } } } Export-ModuleMember -Function Get-CSPoolServices -Alias gpool |