Instantly share code, notes, and snippets.

Bill Long bill-long

View GitHub Profile
View Dump-InternetMessageIds.ps1
#########################################
# Dump-InternetMessageIds.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 / PublicFolderCalendarBind.ps1
Created Sep 6, 2018
Reproduce an error binding to a calendar public folder
View PublicFolderCalendarBind.ps1
#####
# Change as needed
$folderPath = "\Bill\Some Calendar"
$user = "bill@contoso.com"
#
#####
Import-Module -Name "C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll"
$password = $host.ui.PromptForCredential("Credentials", "Please enter your password to authenticate to EWS.", $user, "").GetNetworkCredential().Password
$exchService = new-object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2016)
View Compare-GroupMembership.ps1
# Compare-GroupMembership.ps1
#
# Compares group membership across all GCs to verify replication.
param($Alias)
$forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
$allGCs = $forest.FindAllGlobalCatalogs()
$dictionary = New-Object 'System.Collections.Generic.Dictionary[string, System.Collections.Generic.HashSet[string]]'
foreach ($gc in $allGCs) {
@bill-long
bill-long / RecreatePFs.ps1
Created Jan 12, 2018
When performing New-MailboxRestoreRequest against a PF mailbox, public folders that don't exist in the hierarchy do not get created automatically. The report shows the missing folders. This script uses that report to recreate the hierarchy, so that the restore succeeds on the second attempt.
View RecreatePFs.ps1
# Make sure the report is in the $report variable. Then just copy and paste this into Exchange Management Shell.
$report.Report.MailboxVerification | WHERE { $_.FolderIsMissing } | % {
$path = $_.FolderSourcePath
if (!($path.StartsWith("/IPM_SUBTREE"))) {
continue
}
$path = $path.Substring(12).Replace("/", "\")
$lastSlashIndex = $path.LastIndexOf("\")
@bill-long
bill-long / GenerateIotaSeed.ps1
Last active Dec 8, 2017
Generate IOTA seed in Powershell using RNGCryptoServiceProvider
View GenerateIotaSeed.ps1
# PowerShell script to generate IOTA seed.
# See https://matthewwinstonjohnson.gitbooks.io/iota-guide-and-faq/getting-started/dl-wallet/what-is-my-seed.html
# for seed requirements.
# See https://msdn.microsoft.com/en-us/library/system.security.cryptography.rngcryptoserviceprovider(v=vs.110).aspx
# for the reasoning behind IsFairRoll.
function IsFairRoll($roll, $sides)
{
$fullSetsOfValues = [Byte]::MaxValue / $sides
return $roll -lt $sides * $fullSetsOfValues
View Dump-SearchAndStopIDNAOnEvent.ps1
# Dump-SearchAndStopIDNAOnEvent
###################################
#
# Change these paths as needed.
#
$dumpFolder = 'C:\data'
$procdumpBinary = 'C:\ProgramData\chocolatey\lib\sysinternals\tools\procdump.exe'
$tttracerBinary = 'C:\iDNA\tttracer.exe'
View Test-EWSEndpoints.ps1
# Syntax:
# Test-EWSEndpoints someuser@contoso.com
param($emailAddress)
Import-Module -Name "C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll"
$urls = New-Object 'System.Collections.Generic.List[string]'
# Update these URLs to reflect the URLs you want to test
View Dump-FolderIds.ps1
Get-MailboxFolderStatistics administrator | % { $bytes = [System.Convert]::FromBase64String($_.FolderId); $str = ""; $bytes | % { $str += $_.ToString("X2") }; $_.Name,$str }
View Dump-RuleStream.ps1
#########################################
# Dump-RulesStream.ps1
#
# Dumps PR_RW_RULES_STREAM from IPM.RuleOrganizer
#
# Example:
#
# .\Export-RulesStream.ps1 -HostName e16srv1.contoso.com -UserName admin@contoso.com -Mailbox someuser@contoso.com
#
# Instead of specifying -Mailbox, you can also pass it a file that contains a list of SMTP addresses:
View Delete-RulesAfterDate.ps1
#########################################
# Delete-RulesAfterDate.ps1
#
# Deletes all inbox rules that were created after a certain date.
# The date must be configured below. Also, the script won't actually
# delete anything until you flip $makChanges to $true.
#
# Example:
#
# .\Delete-RulesAfterDate.ps1 -HostName e16srv1.contoso.com -UserName admin@contoso.com -Mailbox someuser@contoso.com