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 / 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 / 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
@bill-long
bill-long / RegexFileSearch.ps1
Last active August 29, 2015 13:59
Search text files for a given regular expression. This is for when findstr won't cut it due to its limited regexp support.
param(
[Parameter(Position=0, Mandatory=$true)]
[string] $Pattern,
[Parameter(Position=1, Mandatory=$false)]
[string] $File,
[Parameter(Mandatory=$false)]
[string] $Directory,
[Parameter(Mandatory=$false)]
[string] $FileFilter,
[Parameter(Mandatory=$false)]
@bill-long
bill-long / Check1216Errors.ps1
Last active August 29, 2015 14:00
Point this to a Directory Service log in CSV format, and it counts each unique 1216 event and tells you how many times that particular type of 1216 event occurred.
param($file)
$reader = new-object System.IO.StreamReader($file)
$errorsDictionary = new-object 'System.Collections.Generic.Dictionary[string,int]'
$nextLineIsError = $false
while ($null -ne ($buffer = $reader.ReadLine()))
{
if ($nextLineIsError)
{
$nextLineIsError = $false
@bill-long
bill-long / CheckToDoSearch.ps1
Created May 30, 2014 15:33
Check search criteria on To-Do Search folder
#########################################
# 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 / Delete-Folder.ps1
Created July 4, 2014 05:58
This script uses Microsoft.Experimental.IO.dll (see http://bcl.codeplex.com/wikipage?title=Long%20Path) to delete folders which contain files where the path exceeds 260 characters. This script recursively deletes all files and folders in the specified folder.
param($folder)
$ExperimentalIOBinary = 'C:\Users\administrator\Desktop\Microsoft.Experimental.IO.dll'
[System.Reflection.Assembly]::LoadFile($ExperimentalIOBinary)
function DeleteAllFilesRecursive($path)
{
"Getting folders in folder: " + $path
$subfolders = [Microsoft.Experimental.IO.LongPathDirectory]::EnumerateDirectories($path)
foreach ($subfolder in $subfolders)
@bill-long
bill-long / Delete-Folder.ps1
Created July 9, 2014 15:32
A Powershell script to delete folders that contain files and directories exceeding the MAX_PATH limit on Windows. Requires Microsoft.Experimental.IO.dll, which can be downloaded from Codeplex: http://bcl.codeplex.com/wikipage?title=Long%20Path
param($folder)
$ExperimentalIOBinary = 'C:\Users\administrator\Desktop\Microsoft.Experimental.IO.dll'
[System.Reflection.Assembly]::LoadFile($ExperimentalIOBinary)
function DeleteAllFilesRecursive($path)
{
"Getting folders in folder: " + $path
$subfolders = [Microsoft.Experimental.IO.LongPathDirectory]::EnumerateDirectories($path)
foreach ($subfolder in $subfolders)
@bill-long
bill-long / Resolve-SIDs.ps1
Created November 19, 2014 20:17
Script for testing the reliability of SID resolution.
# Resolve-SIDs.ps1
#
# Resolve a bunch of SIDs from a text file, in a loop.
param($file)
$sids = New-Object 'System.Collections.Generic.List[string]'
$reader = New-Object System.IO.StreamReader($file)
while ($null -ne ($buffer = $reader.ReadLine()))
{
#################################################################################
# RemoveProperty.ps1
#
# Removes property 0x3FC9 from public folders.
param([string]$FolderPath, [string]$HostName, [string]$UserName, [boolean]$Recurse, [boolean]$Fix)
#################################################################################
# Update the path below to match the actual path to the EWS managed API DLL.
#