I am using this line of code in powershell and it works but it displays too much. I am trying to find and display where the group that contains "Avecto" in the name.
dsquery user -samid MyUSerName| dsget user -memberof | dsget group -samid
Is there anyway to add that on this script statement?
Use the where
keyword in PS (shorthanded here as ?
)
dsquery user -samid MyUSerName| dsget user -memberof | dsget group -samid | ? {$_ -match 'avecto'}
So it would read where each item in the pipeline matches the string 'Avecto'
You could store the data into a variable and manipulate further, as just a simple Object array will be returned if more than one result, otherwise in a single result it will just be a string