I am trying to execute a script remotely to get the list of service with exclusion of certain service currently in stopped state. I am not able to pass the exclusion variable as list.
If i just use it locally it works but within remote invoke command it doesn't.
$exclusionList = 'DoSvc', 'gupdate', 'sppsvc', 'dmwappushservice', 'edgeupdate', 'Intel(R) TPM Provisioning Service', 'wscsvc', 'LPlatSvc', 'Net Driver HPZ12', 'gpsvc', 'Pml Driver HPZ12', 'RstMwService'
$so = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
Invoke-Command -ComputerName $IP -UseSSL -ScriptBlock { param([string]$eList) get-service -Exclude $eList| where {$_.StartType -eq "Automatic" -and $_.Status -eq "Stopped"} -ArgumentList $exclusionList } -SessionOption $so -Credential Computer\User01
Removing $elist from ScriptBlock works. But I do want to pass the value of exclusion of certain service within the sriptblock