Author Posts

September 5, 2014 at 8:01 am

Hi Team,

I want to return only few selected values from a parameter from powershell. Can you please advise me, tried with the below cmdlet but no luck.

$permission = (Get-MailboxPermission -Identity alias).user | Where-Object { $_.user -contains "domainname\sys*" }

I have many users with domainname/sys*, the above cmdlet does not either throw an error nor return a value.
Please advise.

September 5, 2014 at 8:04 am

You probably mean to use the -like operator. The -contains operate is not a wildcard string comparator. Common mistake; see "The Big Book of PowerShell Gotchas" for more information.

September 5, 2014 at 8:05 am

And, as a note, it might be more efficient to:

Get-MailboxPermission -identity alias | Select User | Where { $_.user -like 'whatever*' }

September 5, 2014 at 8:09 am

Excellent Don.

The above command works perfectly as expected.