我正在尝试创建一个小脚本,以便使用PowerShell在Office 365上快速创建简单的收件箱规则。到目前为止,我有以下语法被“-MoveToFolder”参数中的内容挂起。我已经开始重复步骤,所以是时候寻求帮助......
$UserCredential = Get-Credential
$MoveToFolder = Read-Host -Prompt "Destination folder name"
$FromAddressContainsWords = Read-Host -Prompt "Sender info"
$UserEmailAddress = $UserCredential | %{$_.UserName}
Connect-MsolService -Credential $UserCredential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -AllowClobber
New-MailboxFolder -Parent :\Inbox -Name "$MoveToFolder"
$MAlias = Get-Mailbox -Identity "$UserEmailAddress" | %{$_.Alias}
New-InboxRule -Name $MoveToFolder -Mailbox $UserEmailAddress -FromAddressContainsWords $FromAddressContainsWords -MoveToFolder ${'$MAlias:\Inbox\$MoveToFolder'}
Remove-PSSession $Session
答案 0 :(得分:0)
没关系,我不需要你们任何人!这一次......修复了破碎的参数,一切都很好。
-MoveToFolder "$($UserEmailAddress):\$MoveToFolder"