$CommandList = "Get-Mailbox","Get-MailboxStatistics","Disable-Mailbox"
$SessionProperties = @{
ConfigurationName = 'Microsoft.Exchange'
ConnectionUri = "http://$($env:computername).
eridon.ua/powershell"
Authentication = 'Kerberos'
}
$Session = New-PSSession
@SessionProperties -ErrorAction Stop
Import-PSSession $Session -CommandName $CommandList -AllowClobber | Out-Null
$mailboxes = Get-Mailbox -Resultsize Unlimited | where {$_.OrganizationalUnit -like "*
com.ua/Lock*"} | Get-MailboxStatistics | where {$_.Lastlogontime -lt (get-date).AddDays(-90) }
foreach ($mailbox in $mailboxes) {
Disable-Mailbox -Identity $mailbox.DisplayName -Confirm:$false