I am writing a script that moves Exchange 2010 mailboxes using the new-moverequest cmdlet. Whenever one uses the -baditemlimit parameter, the cmdlet displays a warning in yellow text. I want to suppress the warning. In the code snippet below, I have tried setting the warningpreference value as well as using the -warningaction parameter for the cmdlet itself as you can see. In addition, I have also tried setting the warningpreference value by just typing it into the powershell window prior to running the .ps1 file containing the code below.
Even with all three of those things put together, I still get the yellow warning text for each invocation of the commandment, meaning it appears dozens of times. How do I get rid of it? If someone could please show me how the code below needs to be edited, I would appreciate it.
$WarningPreference = "SilentlyContinue"
$userList = Import-Csv $csvfile
foreach ($user in $userList)
write-host "Creating move request for" $user.identity "to database" $targetDB
new-moverequest -identity $user.Identity -targetdatabase $targetdb -baditemlimit 100 -acceptlargedataloss -warningaction "SilentlyContinue"