herestring에서 변수를 사용하는 방법과 나중에 파이프 된 명령에서 변수를 확장하는 방법을 알아낼 수 없습니다. 나는 '
이라는 싱글을 인용하여 "
따옴표를 더블 시도하고 `
문자를 이스케이프한다.
Exchange 그룹의 목록 (예 : 배열과 같은) 및 해당 그룹에 적용 할 조건 목록에이 문자열을 사용하려고합니다.
이# List of groups and conditions (tab delimitered)
$records = @"
Group1 {$_.customattribute2 -Like '*Sales*'}
Group2 {$_.customattribute2 -Like '*Marketing*' -OR $_.customattribute2 -Eq 'CEO'}
"@
# Loop through each line in $records and find mailboxes that match $conditions
foreach ($record in $records -split "`n") {
($DGroup,$Conditions) = $record -split "`t"
$MailboxList = Get-Mailbox -ResultSize Unlimited
$MailboxList | where $Conditions
}
고마워, 내가 찾고있는 Invoke-Expression이 그 것이다! –