Categories
Exchange Scripts

OneLiner: Determine the size of a public folder (and it’s subfolder)

We recently had the request to determine the size of a public folder. Not a problem at all, this should do the trick:

[PS] C:\Windows\system32>Get-PublicFolder "\[Foldername]" | Get-PublicFolderStatistics | Select TotalItemSize

… not really. All we get is the summarized size of the items included in this specific folder. Subfolders and items in subfolders will be ignored. But there is another way which will include subfolder sizes. Here you go:

[PS] C:\Windows\system32>Get-PublicFolder "\[Foldername]" -Recurse | Get-PublicFolderStatistics | Measure TotalItemSize -sum

Optically improved version:

[PS] C:\Windows\system32>Get-PublicFolder "\[Foldername]" -Recurse | Get-PublicFolderStatistics | Measure TotalItemSize -sum | Select @{N='Anzahl der Items'; E={$_.Count}}, @{N='Speicher in Byte'; E={$_.Sum}} | fl

Please be aware that this oneliner may takes some time to complete your request.

Categories
Exchange Server Windows

OneLiner: Get all Mail-Aliases of all Users / Groups in one OU

As we had this request currently, we’ve created the following OneLiners, which i’d like to share with you:

Get all Mailbox-Aliases:

Get-Mailbox -OrganizationalUnit "[DN of OU]" | Select -Expand EmailAddresses Alias | Select SmtpAddress, Alias

Get all DistributionGroup-Aliases:

get-distributiongroup -OrganizationalUnit "[DN of OU]" | Select -Expand EmailAddresses Alias | Select SmtpAddress, Alias
Categories
Exchange Server Windows

Exchange Public Folder – Subsequent Right Management (recursive)

Often you have to add rights for a new user long after the creation of a public folder. If there’s much Data in this folder and it’s subfolders, the usual method by using the Exchange Control Panel will often result in OutOfMemory-Exceptions. To prevent this behaviour, we could use the Exchange Scripts, which were placed on your server during the installation:

  1. At first we need a new Instance of the Exchange Management Shell (EMS) or a PowerShell Console with loaded Exchange Snapins (can be done by using the command “Add-PSSnapin Microsoft.Exchange.Management.Powershell.Snapin”).This needs to be done as the provided Scripts from Microsoft won’t import those Commands again.
  2. In the Shell we will now change our Working-Directory to the Path, were the Scripts are stored. This can be done by the following command:
    cd “C:\Program Files\Microsoft\Exchange Server\V15\Scripts”
    You may replace the Folder “V15” with the Versionnumber of your Exchange-Server.
  3. Now we will execute the following command:
    .\AddUsersToPFRecursive.ps1 -TopPublicFolder “\[folder-path]” -User “[UPN of the User]” -Permission “[Permission-Set]”
    Bsp.: .\AddUsersToPFRecursive.ps1 -TopPublicFolder “\technet” -User “randomguy@c4y.biz” -Permission “Owner”
  4. After a short delay the console will show you every folder as an output-line to confirm the modification of rights.

That’s it!