Just wanted to put this out there since it took me forever to find a solution.
Case: Running server 2012R2 with AD modules installed and Exchange server 2010 management tools. This might affect 2013 as well.
If you start an Exchange Management Shell and try to import-module activedirectory, you will be greeted with a pile error messages because EMS runs in Powershell 3 and 2012R2 AD modules require Powershell 4. Vis versa applies also. Exchange horks up about 98 pages of errors when trying to load the snapin inside powershell 4.
The trick I found was that you can run powershell directly and use -outputformat XML to pass the object to the pipe or a variable.
IE
--Inside Exchange 2010 Management Shell-- (semi paraphrased)
$adusers=(powershell -command {get-aduser -properties HomeMTA | where {$_.homemta -like "OU=Terminated*"}} -outputformat XML)
or
(powershell -command {get-aduser -properties HomeMTA | where {$_.homemta -like "OU=Terminated*"}} -outputformat XML)| foreach {new-moverequest -identity $_.distinguishedname -targetdatabase Archive}
"the more you know."
Hope it helps someone.
Case: Running server 2012R2 with AD modules installed and Exchange server 2010 management tools. This might affect 2013 as well.
If you start an Exchange Management Shell and try to import-module activedirectory, you will be greeted with a pile error messages because EMS runs in Powershell 3 and 2012R2 AD modules require Powershell 4. Vis versa applies also. Exchange horks up about 98 pages of errors when trying to load the snapin inside powershell 4.
The trick I found was that you can run powershell directly and use -outputformat XML to pass the object to the pipe or a variable.
IE
--Inside Exchange 2010 Management Shell-- (semi paraphrased)
$adusers=(powershell -command {get-aduser -properties HomeMTA | where {$_.homemta -like "OU=Terminated*"}} -outputformat XML)
or
(powershell -command {get-aduser -properties HomeMTA | where {$_.homemta -like "OU=Terminated*"}} -outputformat XML)| foreach {new-moverequest -identity $_.distinguishedname -targetdatabase Archive}
"the more you know."
Hope it helps someone.