Newb question, seemed easy enough but I think I am coding something wrong. Basically there is a list of services we want to stop and disable, the list of services are in a text file... then with the gwmi win32_service results I want to do a line by line check to see if the returned wmi .Caption matches an entry in the array of defined services. I just can't get it to work.
$defsvcs
= gc "\\someserver\d$\scripts\ShutdownServices.txt"
$actsvcs
= gwmi win32_service -computerName "servername" | Select Name, Caption
foreach
($svc in $actsvcs){
if ($_.Caption -match $defsvcs){
"Found " + $_.Caption }
}