Dec 08 2021 08:06 AM
Hello
When a knew mailbox is created i want it to be automatically put on litigation hold. What is the best way to do this? We are currently in hybrid Exchange environment
Dec 08 2021 08:24 AM
Dec 08 2021 08:30 AM
Dec 08 2021 09:17 AM
Dec 08 2021 12:05 PM
SolutionDec 08 2021 12:22 PM - edited Dec 08 2021 12:22 PM
Thanks. I want to do a check to see if the mailbox is currently on lithold first. This is what i put together
$pimserviceaccount = "admin.@mycompany.onmicrosoft.com"
$adminpassword = "01000000d08c9ddf0115d1118c7a00c04fc297eb0100000084b78e199e1c3b478efd799c7aab6a910000000002000000000003660000c0000000100000000d19998b9fdab9ec1f44820c65de76fd0000000004800000a000000010000000dce05d1d250d5882967e46b97ecbd0c218000000ab0ceed45aa0a431a0137017b3479b6a6ea8e9694b41327714000000d1b19a01c628ceffedd753a5e2b53d0cd90fb930"
$secureString = ConvertTo-SecureString -String $adminpassword
$cred = New-Object -TypeName PSCredential -ArgumentList $pimserviceaccount, $secureString
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking
$Lithold = Get-MsolUser -all:$true | Where-Object {($_.licenses).AccountSkuId -match "SPE_E5" -or ($_.licenses).AccountSkuId -match "EXCHANGEARCHIVE_ADDON" -or ($_.licenses).AccountSkuId -match "SPE_F1" -or ($_.licenses).AccountSkuId -match "SPE_F5_SECCOMP"} |select UserPrincipalname
$lithold |ForEach-Object {Get-Mailbox -Identity $_.userprincipalname} | Where-Object {$_.litigationholdenabled -eq $false} |set-mailbox -LitigationHoldEnabled:$true
Dec 08 2021 12:05 PM
Solution