Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Get-ADUser and Get-Mailbox

$
0
0

Environment: AD running on Windows 2008R2 and Email on Office 365 (cloud only - not on premise)

I am trying to initially find all mailboxes where LitigationHoldEnabled is set to true in a particular OU and then set those mailboxes to false but I'm running into different errors depending on how I write the commands.  I know this is a syntax error because of my limited knowledge of PowerShell so I'm hoping someone can help.

Scenario 1 with error (I did connect to online session before running these commands):

$quarantineOU = get-mailbox -OrganizationalUnit "OU=Quarantine,DC=domain,DC=corp"

error:

Couldn't find organizational unit "Quarantine". Make sure you have typed the name correctly.

    + CategoryInfo          : NotSpecified: (:) [], ManagementObjectNotFoundException

    + FullyQualifiedErrorId : [Server=BLUPR06MB195,RequestId=89e992ba-ad64-4392-887a-626217e46278,TimeStamp=5/14/2014 4:17:41 PM] [FailureCate

   gory=Cmdlet-ManagementObjectNotFoundException] BD65057B

    + PSComputerName        : pod51043psh.outlook.com

Scenario 2 with error:

$qu = get-aduser -filter * -searchbase "OU=Quarantine, DC=domain, DC=corp"
$qu | ForEach-Object (Get-Mailbox $_.userprincipalname -ResultSize unlimited | where {$_.LitigationHoldEnabled -eq $true})

Error:

ForEach-Object : Parameter set cannot be resolved using the specified named parameters.

At line:2 char:7

+ $qu | ForEach-Object (Get-Mailbox $_.userprincipalname -ResultSize unlimited | w ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : MetadataError: (:) [ForEach-Object], ParameterBindingException

    + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.ForEachObjectCommand


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>