Fr. Vandecan
asked on
Combine a variable and a * into a filter
Include Variable AND a "*" into a query.
for ex :
$MailboxAlias = "DCH"
$ArrMailbox = @(Get-Mailbox -RecipientTypeDetails SharedMailbox -filter 'samaccountname -like "DCH*"' --> $ArrMailbox = @(Get-Mailbox -RecipientTypeDetails SharedMailbox -filter 'samaccountname -like "$Mailboxalias*"'
How to achieve this cause -like "$Mailboxalias*"' does not do -like "DCH*"' ?
for ex :
$MailboxAlias = "DCH"
$ArrMailbox = @(Get-Mailbox -RecipientTypeDetails SharedMailbox -filter 'samaccountname -like "DCH*"' --> $ArrMailbox = @(Get-Mailbox -RecipientTypeDetails SharedMailbox -filter 'samaccountname -like "$Mailboxalias*"'
How to achieve this cause -like "$Mailboxalias*"' does not do -like "DCH*"' ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Whether you have the asterisk defined as part of the variable or not, the outer quotes must be double-quotes for the variable to be evaluated inside the filter string.
Open in new window