Tag Archives: Exchange

Get FolderID (FolderStoreID) for all mailboxes

 

# Get-AllMailboxFolderStatistics.ps1
#
# Can be used to pull FolderID for all mailboxes (FolderID is often referenced in the audit logs).
#
# This can take a large time to run depending on number of mailboxes and number of folders (15 minutes is not uncommon)
#
# Outputs to a file called AllMailboxFolderStatistics.csv - this can grow into tens of MB, and in excess of 10000 rows, depending on tenant.
# If the file exists at the start, the script will abort.

$OutputFile="AllMailboxFolderStatistics.csv"
if(-Not (test-path -path $OutputFile))
{
    $Mailboxes=Get-Mailbox
    foreach ($Mailbox in $Mailboxes)
    {
        $stats=get-exomailboxfolderstatistics -userprincipalname $mailbox.userprincipalname
        $stats | export-csv $OutputFile -notype -append
    }
}
else
{
    write-error "$OutputFile already exists - please remove this file before running."
}

 

Exchange connectivity test fails when certificate doesn’t match name

I had a scenario where I was using a single name SSL certificate which was setup for mail.domain.test.  I needed to get autodiscover to work for this domain name.  The DNS host was Godaddy.

I configured an SRV record as follows:

The target pointed to the certificate name.  EG: mail.domain.test.  This allowed the https://testconnectivity.microsoft.com test to go through.

 

References:

https://au.godaddy.com/help/outlook-windows-manually-add-autodiscover-srv-record-20066

Connect to Exchange powershell remotely

Connect to Exchange powershell remotely using the following commands

$exchCred=Get-Credential
$exchUri=”
http://servername/powershell”

$exchSession=New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $exchUri -Authentication Kerberos -Credential $exchCred
Import-PSSession $exchSession

$exchCred is the credentials used to connect

$exchUri is the Uri of the Exchange server powershell virtual directory.  EG: http://exchange.anonit.net/powershell

 

To remove the session at the end, use Remove-PSSession $exchSession

 

See the powershell script here

 

Reference:

https://community.spiceworks.com/scripts/show/3956-connect-to-exchange-powershell-remotely