Forum Discussion
Robert Bollinger
Sep 13, 2021Brass Contributor
Mailbox Rules, PowerShell and Scripting.
Hey Guys, I am trying to create a powershell script that will create a mailbox rule in each users mailbox, based on an input list. Here is what i have so far: New-InboxRule -Mailbox $S...
pvanberlo
Sep 14, 2021MCT
Would need a bit more of your script. But generally you’d do something like this:
$Mailboxes = Import-CSV .\mailboxes.csv
ForEach ($Mailbox in $Mailboxes) {
// Insert the code above but replace SingleImport with Mailbox
}
On mobile right now, so can’t make it pretty etc.
$Mailboxes = Import-CSV .\mailboxes.csv
ForEach ($Mailbox in $Mailboxes) {
// Insert the code above but replace SingleImport with Mailbox
}
On mobile right now, so can’t make it pretty etc.
Robert Bollinger
Sep 14, 2021Brass Contributor
I forgot to post this last night:
$Importlist = Import-CSV Test_Email_Rule.csv
foreach ($SingleImport in $importlist)
{
New-InboxRule -Mailbox $SingleImport.PrimarySMTPAddress -From user.name@domain.com -MyNameInToBox $True -SubjectContainsWords '["Receipt Copy"] Hello' -Name TestEmailRule -MoveToFolder “$($SingleImport.PrimarySMTPAddress):\Sent Items"
}
Thats my complete script.