Skip to content

Instantly share code, notes, and snippets.

View tostka's full-sized avatar

Todd Kadrie tostka

View GitHub Profile
@tostka
tostka / ExOpRetryLogic.md
Created August 10, 2022 21:59
Exch Onprem Retry Logic Flowchart (mermaid)
flowchart TD
  EStart([Message arrives at queue]) --> A1TrySend[Exchange tries to deliver message]
  A1TrySend -->D1{Message can be sent?}
  D1 -->|Yes| EvtDelivered([Message Delivered Externally])
  D1 -->|No| D1A500{Error -class returned?}
  D1A500 -->|500 Perm Fail| EvtNDR([Send Sender NDR Failure])
  D1A500 -->|400 Retryable| D1BExpired{"MessageExpirationTimeout expired? <br/>(2d)"}
  D1BExpired -->|Yes| EvtNDR
  D1BExpired -->|No| D1CDsn{"DelayNotificationTimeOut expired?<br/>(4h)"}
@tostka
tostka / convert-HelpToMarkdown.ps1
Last active September 14, 2021 22:10 — forked from opariffazman/Get-HelpByMarkdown.ps1
This script converts PowerShell comment-based help to GitHub Flavored Markdown.
Function convert-HelpToMarkdown {
<#
.SYNOPSIS
convert-HelpToMarkdown.ps1 - Gets the comment-based help and converts to GitHub Flavored Markdown text (for separate output to .md file).
.NOTES
Version : 1.0.0
Author : Todd Kadrie
Website : http://www.toddomation.com
Twitter : @tostka / http://twitter.com/tostka
CreatedDate : 2021-09-14
@tostka
tostka / 20190715-1216PMP.ps1
Created July 17, 2019 23:19
Get recreated EXO mbx status
get-exomailbox $tAddress ; get-recipient $tAddress | ft -a Name, RecipientT* ;
@tostka
tostka / 20190715-1216PMO.ps1
Created July 17, 2019 23:18
One-Liner recreate RemoteMailbox against recreated EXOMailbox
$whatif=$true ;$exombx=get-exomailbox $tAddress ;$RemoteRoutingAddress=($exombx.emailaddresses |?{$_ -match '.*.mail\.onmicrosoft\.com'}).replace("smtp:","");$pltEnable=[ordered]@{ Identity=$exombx.alias ; RemoteRoutingAddress=$RemoteRoutingAddress ; whatif=$($whatif) ;} ;write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):Enable-RemoteMailbox w`n$(($pltEnable|out-string).trim())" ;Enable-RemoteMailbox @pltEnable;if(!$whatif){ $pltSet=[ordered]@{ Identity=$exombx.alias ; ExchangeGuid=$exombx.ExchangeGuid ; whatif=$($whatif) ; } ; write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):Set-RemoteMailbox w `n$(($pltSet|out-string).trim())" ; Set-RemoteMailbox @pltSet ; get-remotemailbox -id $exombx.alias | select userprin*,samac*,recipientt* ;} ;
@tostka
tostka / 20190715-1216PMN.ps1
Created July 17, 2019 23:17
Recreate OPX RemoteUser mapping to recreated EXO mbx
$whatif = $true ;
$exombx = get-exomailbox $tAddress ;
$RemoteRoutingAddress = ($exombx.emailaddresses | ? { $_ -match '.*.mail\.onmicrosoft\.com' }).replace("smtp:", "");
$pltEnable = [ordered]@{
Identity = $exombx.alias ;
RemoteRoutingAddress = $RemoteRoutingAddress ;
whatif = $($whatif) ;
} ;
write-host -foregroundcolor green "$((get-date).ToString('HH:mm:ss')):Enable-RemoteMailbox w`n$(($pltEnable|out-string).trim())" ;
Enable-RemoteMailbox @pltEnable;
@tostka
tostka / 20190715-1216PMM.ps1
Created July 17, 2019 23:16
Get updated OPX & EXO recipienttypes
rxo ; get-exomailbox $tAddress ; rx10 ; get-recipient $tAddress | ft -a Name, RecipientT* ;
@tostka
tostka / 20190715-1216PML.ps1
Created July 17, 2019 23:15
Re-poll updated MsolUser status
$msolu = get-MsolUser -UserPrincipalName $adu.userprincipalname ; $msolu | format-list userprin*, *Error*, *status*, softdel*, lic*, islic*
@tostka
tostka / 20190715-1216PMK.ps1
Created July 17, 2019 23:13
Wait for AD object to replicate to AzureAD
# AAD replication dawdle loop:
# 1-line, note, the get-msoluser cmdlet lacks an erroraction param, which causes it to error every pass. But the code plows on until object is returned replicated
Do { write-host "." -NoNewLine; $msolu = get-MsolUser -UserPrincipalName $adu.userprincipalname ; start-sleep -s 30 ; } Until($msolu) ; write-host "`a" ; write-host "`a" ; write-host "`a" ; $msolu | format-list userprin*, *Error*, *status*, softdel*, lic*, islic* ;
@tostka
tostka / 20190715-1216PMJ.ps1
Created July 17, 2019 23:12
Move ADUser back to original OU
# confirm $origOU was properly configured up in step 1.
$origOU ;
# move the ADUser object to the $origOU, note -whatif needs to be removed to execute
Move-ADObject -Identity $adu.ObjectGUID.guid -TargetPath $origOU -whatif ;
# confirm current location
get-aduser $adu.samaccountname | format-list dist* ;
@tostka
tostka / 20190715-1216PMI.ps1
Created July 17, 2019 23:10
Clear ADUser mail-attributes on-prem
# note -whatif needs to be removed to execute
set-aduser -Identity $adu.samaccountname -clear msExchMailboxGuid, msexchrecipientdisplaytype, msexchrecipienttypedetails -whatif;
# confirm attributes cleared
get-aduser -Identity $adu.samaccountname -prop * | format-list msExchMailboxGuid, msexchrecipientdisplaytype, msexchrecipienttypedetails ;