[Powershell Basics] Find substring in string array
Imagine that you have array of strings (email addresses for example):
one-domain.ru
two-domain.ru
three-domain.com
four-domain.com
five-domain-company.com
You have a task - find email addresses in domain domain.ru among these strings.
You can solve this in the following way:
PS H:\> $array one-domain.ru two-domain.ru three-domain.com four-domain.com five-domain-company.com PS H:\> PS H:\> $array -like "*domain.ru*" one-domain.ru two-domain.ru PS H:\>
How can you use that?
Such trick can be used when you need to find Exchange users which have e-mail addresses in some specific domain.
Imagine now that you have array of arrays. You can encounter this when you run Get-MailBox. In this case search command will look like this:
Get-Mailbox | %{$_.emailaddresses -like "*domain.ru*"}
Thats it.
powershell (ru), exchange (ru)
- Hits: 12618