im a writing a script in powershell that show services running on a computer and start the services that is not running. My command is the following
Show all services on Powershell with startmode "Auto"
$shse = Get-CimInstance -ClassName win32_service -Computername pshells '
-Filter "startmode = 'auto'" |
ConvertTo-Html
Service start all services with status = stopped.
$Service = (Get-CimInstance -ClassName win32_service - Computername pshells '
-Filter "startmode = 'auto'")
If ($Service.status -eq "Stopped"){
Start-Service}
Else {}
Convert Output to HTML.
ConvertTo-Html -body "$shse " |
Out-File C:\Scripts\Service.htm
When running this in powershell i get this error
At line:6 char:30
+ -Filter "startmode = 'auto'")
+ ~
Unexpected token ')' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordExceptio
n
+ FullyQualifiedErrorId : UnexpectedToken
pshellsis not closed.'but a`.-andComputername