0

I'm trying to create a little script to quickly create simple inbox rules on Office 365 using PowerShell. Thus far I have the following syntax that is getting hung up by what I have in the '-MoveToFolder' parameter. I've started repeating steps so it's time to ask for help...

$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
1
  • Down-voted because?? Commented Dec 5, 2017 at 14:48

1 Answer 1

1

Nevermind, I don't need any of you! This time... Fixed the broken parameter and all is well now.

-MoveToFolder "$($UserEmailAddress):\$MoveToFolder"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.