Monthly Archives: April 2014

Exchange 2010 local move request stuck at queued

I was trying to do a local move request, but the move request was getting stuck at queued, 0%.

In our environment, we are running a production DAG of a database. All the databases were showing a healthy status.

Getting the move request statistics showed nothing:

Get-MoveRequest | Get-MoveRequestStatistics | fl

I ran across an article that said to set the DataMoveReplicationContraint from SecondCopy to None.

Set-MailboxDatabase -Identity databasename -DataMoveReplicationConstraint None

This change requires a restart of the Exchange Replication Manager service on all CAS servers.

After you are complete you need to set the mailbox database DataMoveReplicationConstraint back to SecondCopy.

Set-MailboxDatabase -Identity databasename -DataMoveReplicationConstraint SecondCopy

Powershell Office 365 Calendar Permissions with Task Scheduler

Recently was requested to set the calendar permissions for all our Office 365 mailboxes.
Here are the instructions:

Create a password file for the Office 365 user

Read-Host -AsSecureString “Office 365 password?” | ConvertFrom-SecureString | Out-File C:\Scripts\Office365cred.txt

Create a powershell scritp file UpdateCalendar-O365.ps1

if ((Get-PSSnapin | Where-Object {$_.Name -like "Microsoft.Exchange.Management.PowerShell.E2010"})){
Remove-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Write-Output "Loading O365 Environment"

Set-ExecutionPolicy RemoteSigned
$User = “”

$Pass = Get-Content C:\Scripts\Office365cred.txt | ConvertTo-SecureString
$PSCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $Pass
$O365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Authentication Basic -AllowRedirection -Credential $PSCred
$ImportSession = Import-PSSession $O365Session

Write-Output “Loaded O365 Environment”

Write-Output “Loading mailboxes”
#Custom variables
$mailboxes = Get-Mailbox -ResultSize Unlimited

Write-Output “Loaded mailboxes”
$AccessRights = “Reviewer”

#Loop through all mailboxes
foreach ($mailbox in $mailboxes) {

Write-Output “Looking up $mailbox”
$calendar = (($mailbox.Identity)+ “:\” + (Get-MailboxFolderStatistics -Identity $mailbox.Identity | where-object {$_.FolderType -eq “Calendar”} | Select-Object -First 1).Name)

$access = ((Get-MailboxFolderPermission $calendar | Where-Object {$_.User -like “Default”}).AccessRights)

#Check if calendar-permission for user “Default” is set to the default permission of “AvailabilityOnly”
if ($access -like “AvailabilityOnly” ) {
Write-Output ” Updating calendar permission for $mailbox…”
#Set calendar-permission for user “Default” to value defined in variable $AccessRights
Set-MailboxFolderPermission -User “Default” -AccessRights $AccessRights -Identity $calendar
} elseif ($access -like $AccessRights ) {
Write-Output ” $AccessRights calendar permission for $mailbox already set.”
} elseif ($access -like “None” ) {
Write-Output ” Changing calendar permission for $mailbox from None…”
#Set calendar-permission for user “Default” to value defined in variable $AccessRights
Set-MailboxFolderPermission -User “Default” -AccessRights $AccessRights -Identity $calendar
} else {

Write-Output ” Permission set to $access for $mailbox.”

Write-Output “Removing O365 Environment”
Remove-PSSession $O365Session
Write-Output “Removed O365 Environment”

Within Task Scheduler, Create New Task…
Specify the name, run whether user is logged on or not, and Run with highest privileges.

Set the triggers

Under the Actions Tab:

Program = C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add arguments = -command "C:\scripts\UpdateCalendar-O365.ps1" > "C:/scripts/UpdateCalendar-O365-Output.txt"

This should generate an output script text file so you can monitor the progress.