Link to home
Start Free TrialLog in
Avatar of bibi92
bibi92Flag for France

asked on

find string in list

Hello,

How can check  if $SvcLoAS is contained on in list ?

Thank you
regards 

$SvcLoAS = (Get-WmiObject -Query "Select StartName from Win32_Service WHERE Name = 'COM\svc_sql' "  | Format-Table StartName -HideTableHeaders | Out-String).Trim()
   $ListSvc = 'COM\svc_sql' , 'COMM\svc_sqltest'
   
   If ($SvcLoAS -contains $ListSvc) {
      Write-Host " "svc_sql"  starts with $SvcLoAS" -ForegroundColor green
   } else {
      Write-Host " "svc_sql"  not start with $SvcLoAS" -ForegroundColor White -BackgroundColor red
   }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial