People claim select-string is like grep...
-
Yet it cant look through output of a cmdlet like
Get-SmbServerConfiguration
Seems ok so far
Get-SmbServerConfiguration | select-string "Auto*"
Clearly these should be returning something.However it does work for things like netstat
I could take Get-SmbServerConfiguration output to a text file then parse it, but why cant PS just read this? -
Get-SmbServerConfiguration | Select-Object "Auto*"
-
@momurda Have you tried using -Pattern with it? I.e. Get-SmbServerConfiguration | select-string -Pattern "Auto"
-
@kelly said in People claim select-string is like grep...:
@momurda Have you tried using -Pattern with it? I.e. Get-SmbServerConfiguration | select-string -Pattern "Auto"
That didn't work when I tried it.
-
@black3dynamite Oh i suppose that means the result of Get-SMBServerConfiguration is not string but a list of objects.
-
@momurda said in People claim select-string is like grep...:
@black3dynamite Oh i suppose that means the result of Get-SMBServerConfiguration is not string but a list of objects.
That's generally the case, and that's why PS is so complex and confusing. Bash uses straight text, always. So tools are universal and obvious. PS uses a mix of outputs and presents all as text but refuses to process them as such under certain cases. So you can't see what the output is, it takes extra steps to determine. It's not deterministic from an interface perspective making it confusing, complex, and to some degree risky because what should be obvious behaviour is not and things like filtering can yield inaccurately perceived results for this reason.
-
@momurda if you doubt what type (object/string/anything) is returned, try using $a.GetType() and it will return you the variable type.