Skip to content

Instantly share code, notes, and snippets.

View bill-long's full-sized avatar

Bill Long bill-long

  • Microsoft
View GitHub Profile
@bill-long
bill-long / Delete-TNEFProps.ps1
Last active January 4, 2016 05:18
Delete-TNEFProps.ps1 is a script intended to fix the Exchange Public Folder Replication issue described here: http://bill-long.com/2014/01/16/public-folder-replication-fails-with-tnef-violation-status-0x00008000/
#################################################################################
#
# The sample scripts are not supported under any Microsoft standard support
# program or service. The sample scripts are provided AS IS without warranty
# of any kind. Microsoft further disclaims all implied warranties including, without
# limitation, any implied warranties of merchantability or of fitness for a particular
# purpose. The entire risk arising out of the use or performance of the sample scripts
# and documentation remains with you. In no event shall Microsoft, its authors, or
# anyone else involved in the creation, production, or delivery of the scripts be liable
# for any damages whatsoever (including, without limitation, damages for loss of business
@bill-long
bill-long / Create-LotsOfPFs.ps1
Created January 26, 2014 15:24
Powershell script to create a lot of public folders for testing.
# Create-LotsOfPFs.ps1
#
# Creates 10,000 public folders
function CreateFoldersRecursive($parentFolder)
{
$currentDepth++
for ($x = 1; $x -le $foldersPerLevel; $x++)
{
$thisFolder = New-PublicFolder ("Folder " + $x.ToString()) -Path $parentFolder.Identity.ToString()
@bill-long
bill-long / GenericDoAllPublicFoldersScript.ps1
Last active January 4, 2016 20:49
Generic script to iterate through public folders and do something via EWS. Use this as a basis for other scripts.
#################################################################################
# GenericDoAllPublicFoldersScript.ps1
#
# Generic script to do something to all public folders via EWS. Just change
# DoFolder to do what you want.
param([string]$FolderPath, [string]$HostName, [string]$UserName, [boolean]$Recurse)
#################################################################################
# Update the path below to match the actual path to the EWS managed API DLL.
@bill-long
bill-long / GenericDoAllMailboxFoldersScript.ps1
Last active July 5, 2018 00:12
Generic script to use Exchange Web Services Managed API do something to all items in all folders in a mailbox. Modify for your specific purpose.
#########################################
# GenericDoAllMailboxFoldersScript.ps1
#
param([string]$HostName, [string]$UserName, [string]$Mailbox, [string]$InputFile)
#########################################
# Update the path below to match the actual path to the EWS managed API DLL.
#
@bill-long
bill-long / DumpItemSubjects.ps1
Created January 28, 2014 22:09
Display the subjects of all items in one or more mailboxes.
#########################################
# DumpItemSubjects.ps1
#
# Dumps the subjects of all items in the specified mailbox or mailboxes.
# You can specify one mailbox with -Mailbox, or specify multiple mailboxes
# by passing -InputFile and pointing to a file that contains a list of
# email addresses, one on each line.
#
# To capture the results, use Start-Transcript.
#
@bill-long
bill-long / Fix-DelegatedSetup.ps1
Last active August 29, 2015 13:56
In Exchange 2013, delegated setup will fail if legacy administrative groups exist. This script will add an explicit deny for the Delegated Setup group to allow setup to work. The script can be run again once setup is complete to remove the deny.
# Fix-DelegatedSetup.ps1
#
# In Exchange 2013, delegated setup fails if legacy admin groups still exist. However,
# it's recommended that these admin groups not be deleted. To make delegated setup work,
# you can temporarily place an explicit deny so that the Delegated Setup group
# cannot see them. This script automates that process.
#
# This script takes no parameters. The syntax is simply:
# .\Fix-DelegatedSetup.ps1
#
@bill-long
bill-long / Sync-ReplState.ps1
Last active March 20, 2017 18:23
Sync ReplState table after running public folder repair request on Exchange 2010.
# Sync-ReplState.ps1
#
# After running a ReplState repair, it is often necessary to change
# the replica list on the affected folders by removing and re-adding
# the database in order to sync the data in the ReplState table with
# the Folders table.
#
# The purpose of this script is to scan the application log for the
# latest ReplState fix, get a list of the affected FIDs, then find
# those FIDs and modify the replica list, thus causing it to sync up.
@bill-long
bill-long / Find-UnlinkedPFProxies.ps1
Last active May 15, 2020 03:35
Find Exchange Server public folder directory objects that are not linked to any existing folder. See also: https://gist.github.com/bill-long/e1de3ea480837e1a2742 and http://bill-long.com/2014/03/08/cleaning-up-microsoft-exchange-system-objects-part-2/
$gcRootDSE = [ADSI]"GC://RootDSE"
$gcRoot = [ADSI]("GC://" + $gcRootDSE.dnsHostName)
"Using " + $gcRoot.Path
# Find all the PF proxies
"Finding all public folder directory objects..."
$pfProxyFinder = new-object System.DirectoryServices.DirectorySearcher($gcRoot, "(objectClass=publicFolder)")
$pfProxyFinder.PageSize = 100
$allPfProxies = $pfProxyFinder.FindAll()
"Found " + $allPfProxies.Count.ToString() + " public folder directory objects."
@bill-long
bill-long / Create-BigObjects.ps1
Created March 20, 2014 05:50
The purpose of this script is to create some very large user objects in order to hit the LDAP send queue limit in Active Directory using this tool: https://github.com/bill-long/LdapSendQueueTest
# Create-BigObjects.ps1
$dcName = "DC1"
$domain = "DC=bilong,DC=test"
$bigObjectContainer = "BigObjects"
Import-Module ActiveDirectory
$adModule = Get-Module | WHERE { $_.Name -eq "ActiveDirectory" }
if ($adModule -eq $null)
{
# Fix-MailEnabled.ps1
#
# The purpose of this script is to read an ExFolders or PFDAVAdmin
# property export of public folders, and fix the folders where the
# mail-enabled state is not consistent.
#
# The export must include the following properties:
# PR_PF_PROXY, PR_PF_PROXY_REQUIRED, DS:proxyAddresses
#
# The export can optionally include the following