This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param([string]$ExeName) | |
# For some reason, when a process stops the event doesn't always have the trailing e | |
$ExeStopName = $ExeName.Substring(0, $ExeName.Length - 1) | |
# Watch for process start events | |
$startEventQuery = New-Object System.Management.WqlEventQuery("SELECT * FROM Win32_ProcessStartTrace WHERE ProcessName = `"$ExeName`"") | |
$startWatch = New-Object System.Management.ManagementEventWatcher($startEventQuery) | |
Register-ObjectEvent $startWatch -EventName EventArrived -SourceIdentifier "ProcessStarted" | |
$startWatch.Start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GetRealDefaultPFMailboxValue.ps1 | |
# | |
# In Exchange Management Shell, DefaultPublicFolderMailbox shows a random | |
# value if the value is not set on the mailbox. This makes it difficult | |
# to determine whether this value has been set on a mailbox or not. | |
# | |
# The purpose of this script is to take a set of mailboxes and retrieve | |
# the actual DefaultPublicFolderMailbox value. | |
# | |
# To use this script, retrieve the mailboxes you want to process and pipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################# | |
# | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################# | |
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################### | |
# 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. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$targetDatabases = New-Object 'System.Collections.Generic.List[string]' | |
$targetDatabases.AddRange([string[]]@("MBDB1", "MBDB2", "MBDB3")) | |
Add-Type @" | |
using System; | |
public class MailboxMoveInfo { | |
public string Caller; | |
public DateTime RunDate; | |
public string Mailbox; | |
public string TargetDatabase; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################### | |
# LogonToMailboxesViaEWS.ps1 | |
# | |
param([string]$InputFile) | |
######################################### | |
# Update the path below to match the actual path to the EWS managed API DLL. | |
# Can be downloaded at: http://www.microsoft.com/en-us/download/details.aspx?id=42951 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example: | |
# C:\> .\ConvertPrStartTimeEtc.ps1 000000009EC59B2B409ED001 | |
# | |
# Wednesday, June 3, 2015 8:59:24 PM | |
param($byteString) | |
$bytesReversed = "" | |
for ($x = $byteString.Length - 2; $x -gt 7; $x-=2) { $bytesReversed += $byteString.Substring($x, 2) } | |
[DateTime]::FromFileTimeUtc([Int64]::Parse($bytesReversed, "AllowHexSpecifier")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example: | |
# C:\> .\ConvertGuid DB62390413BF4DDF86D69EAC9ED013D9 | |
# | |
# Guid | |
# ---- | |
# 043962db-bf13-df4d-86d6-9eac9ed013d9 | |
param([string]$guidByteString) | |
[byte[]]$guidBytes = @() | |
for ($x = 0; $x -lt $guidByteString.Length; $x+=2) { $guidBytes += [Byte]::Parse($guidByteString.Substring($x, 2), "AllowHexSpecifier") } |