Its very basic Here is what I am trying to accomplish:
#Make a list of programs depending on Input
get-service | Where-Object {$_.name -Like $Input}| select-object name, DisplayName, ServiceType, Status
get-service | Where-Object {$_.name -Like "Sys*"}| select-object name, DisplayName, ServiceType, Status
Now the second get-service works no problem. But the first one does not cooperate with me, it just throws all the services on the server.
I obtain the user input with this:
$Input = Read-Host -Prompt 'Input your regex'
So what is going on here. Where have I gone wrong? And no, I test the variable with a write-host, the string is there. Its not disappearing as far as I can tell.
$inputis an automatic variable, it'll get overwritten for every iteration ofWhere-Object. ConsiderGet-Service | Where-Object {Write-Host ($_ -eq $input[0]) }