Exchange Shell one-liner: Get last night online defrag statistics

Exchange writes an event once the online defragmentation process ends. This one-liner gets events written on the last day:
Get-EventLog -LogName Application | Where-Object { $_.eventID -eq 12
21 -and (New-TimeSpan $_.TimeGenerated $(get-Date)).days -lt 1} | select message


Message
-------
The database "SG1\MBX1" has 0 megabytes of free space after online defragmen...

Advertisements

Script to fix issues with sending of attachments from Exchange to Notes (KB924240)

This script fix the issue reported on http://support.microsoft.com/?scid=kb;en-us;924240

It’s a powershell script that modify all mail users (not mailbox users) from the search base that you specify, setting mAPIRecipient as FALSE. It’s based on a generic script to do AD modifications, found at http://www.gilham.org/Blog/Lists/Posts/Post.aspx?ID=108

# Modify Search root:
$SearchRoot = "dc=use3,dc=local"

# Filter by mail users, that is: class = user,
# Exchange alias set and HomeServer no set
$Filter = "(&(objectClass=user)(!msExchHomeServerName=*)(mailNickname=*))"

$Scope = "subtree"

# mAPIRecipent = FALSE, No winmail.dat will be sent to mail users.

$Attribute = "mAPIRecipient"
$Value = "FALSE"

$Searcher = new-object DirectoryServices.DirectorySearcher
$Root = [ADSI]("LDAP://" + $SearchRoot)

$Searcher.SearchScope = $Scope
$Searcher.Filter = $Filter
$Searcher.SearchRoot = $Root

$UserList = $Searcher.FindAll()

foreach($User in $UserList)
{
  write-host $User.Path
  $UserADSI = [ADSI]$User.Path
  $CurrentValue = $UserADSI.Get($Attribute)
  write-host "Current Value is" $CurrentValue -ForeGroundColor White
  $Put = $UserADSI.Put($Attribute,$Value)
  $Set = $UserADSI.SetInfo()
  write-host "New value is" $UserADSI.Get($Attribute)
}