Skip to content

Instantly share code, notes, and snippets.

View JeremyTBradshaw's full-sized avatar
🤠
Yeehaw

Jeremy JeremyTBradshaw

🤠
Yeehaw
View GitHub Profile
@JeremyTBradshaw
JeremyTBradshaw / Some-OutlookCalendarOverrides.ps1
Created March 1, 2024 20:31
Some Outlook Calendar registry overrides
# https://support.microsoft.com/en-us/office/user-experience-changes-for-sharing-a-calendar-in-outlook-5978620a-fe6c-422a-93b2-8f80e488fdec
reg add HKCU\SOFTWARE\Microsoft\Office\16.0\Outlook\Options\Calendar /v ShowLegacySharingUX /t REG_DWORD /d 1
# https://support.microsoft.com/en-us/office/how-to-revert-the-outlook-desktop-webview-based-room-finder-to-the-legacy-room-finder-e872b6f2-0d36-41ff-861d-adaab2da9c28?ui=en-US&rs=en-US&ad=US
reg add HKCU\SOFTWARE\Microsoft\Office\16.0\Outlook\Options\Calendar /v ShowLegacyRoomFinder /t REG_DWORD /d 0
@JeremyTBradshaw
JeremyTBradshaw / Set-ExchangeAutomaticServices.ps1
Last active October 4, 2023 18:32
Fix Exchange disabled services after failed SU/CU installs
@"
HostControllerService
MSComplianceAudit
MSExchangeADTopology
MSExchangeAntispamUpdate
MSExchangeCompliance
MSExchangeDagMgmt
MSExchangeDelivery
MSExchangeDiagnostics
MSExchangeEdgeSync
@JeremyTBradshaw
JeremyTBradshaw / Get-BackPressureStatus.ps1
Created May 29, 2023 16:22
Get Exchange Back Pressure Status and Thresholds Summary.
# Longer version: https://github.com/JeremyTBradshaw/PowerShell/blob/main/Get-BackPressureStatus.ps1
# Reference: https://learn.microsoft.com/en-us/exchange/mail-flow/back-pressure#view-back-pressure-resource-thresholds-and-utilization-levels
$TransportServers = Get-TransportService
$backPressureDiagInfo = foreach ($srv in $TransportServers) {
[xml]$perServerBPDiagInfo = Get-ExchangeDiagnosticInfo -Server $srv.Name -Process EdgeTransport -Component ResourceThrottling
foreach ($rsrc in $perServerBPDiagInfo.Diagnostics.Components.ResourceThrottling.ResourceTracker.ResourceMeter) {
$rsrc | Select-Object @{Name = 'Server'; Expression = { $srv.Name } },
@JeremyTBradshaw
JeremyTBradshaw / IPRegex.ps1
Created May 17, 2023 23:41
Regex validation for IPv4 addresses, optionally with CIDR notation
$IPRegex = @(
'^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}', #<-: 0. to 255. (x3)
'([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])', #<---------: 0 to 255
'($|/([8-9]|[1-2][0-9]|3[0-2]))$' #<-----------------------------: (optional) /8 to /32
) -join ''
$Variations = @(
# Will match:
'0.0.0.0',
'10.0.0.0/8',
@JeremyTBradshaw
JeremyTBradshaw / New-Password.ps1
Last active April 13, 2023 01:02
PowerShell Password Generator
<#
.Synopsis
Generate one or more random passwords, from 7 to 64 characters in length.
.Description
Passwords are generated using an equal distribution of upper and lower case letters, numbers, space, and special
characters found on the number row.
.Parameter Length
Specifies the length of the generated password(s).
@JeremyTBradshaw
JeremyTBradshaw / ExchangeServerTLS1.2.reg
Last active February 18, 2023 18:21
Quickly enable TLS1.2 and disable PCT1.0, SSL2.0, SSL3.0, TLS1.0, and TLS1.1
Windows Registry Editor Version 5.00
;#======#---------------#
;#region# .NETFramework #
;#======#---------------#
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727]
"SystemDefaultTlsVersions"=dword:00000001
"SchUseStrongCrypto"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
@JeremyTBradshaw
JeremyTBradshaw / ConvertFrom-SecureStringToPlainText.ps1
Last active January 30, 2023 09:30
For PowerShell 5.1 and older, convert secure strings back to plain text
function ConvertFrom-SecureStringToPlainText ([System.Security.SecureString]$SecureString) {
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto(
[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString)
)
}
New-Alias -Name s2p -Value ConvertFrom-SecureStringToPlainText
@JeremyTBradshaw
JeremyTBradshaw / ConvertFrom-DistinguishedName.ps1
Created August 5, 2022 12:01
Convert DistinguishedName's to CanonicalName's
function ConvertFrom-DistinguishedName ($DistinguishedName) {
$Domain = ($DistinguishedName -split ',DC=' | Where-Object { $_ -notmatch '^CN=' }) -join '.'
$CNPath = ($DistinguishedName -split ',DC=' | Where-Object { $_ -match '^CN=' }) -split ',\w\w='
[array]::Reverse($CNPath)
($Domain + '/' + ($CNPath -join '/')) -replace 'CN=' -replace '\\'
}
ConvertFrom-DistinguishedName "CN=Bradshaw\, Jeremy,OU=PowerShell,DC=Sample,DC=code"
@JeremyTBradshaw
JeremyTBradshaw / GuidToImmutableIdAndBack.ps1
Last active July 27, 2022 14:13
Convert between Guid and ImmutableId (for Azure AD / Office 365 customers)
#Requires -Version 3
function ConvertFrom-GuidToImmutableId ([Guid]$Guid){
[System.Convert]::ToBase64String([Guid]::Parse($Guid).ToByteArray())
}
New-Alias -Name g2i -Value ConvertFrom-GuidToImmutableId
function ConvertFrom-ImmutableIdToGuid ([string]$ImmutableId) {
@JeremyTBradshaw
JeremyTBradshaw / Exchange_pre-CU_Backup.ps1
Created March 5, 2021 00:44
Exchange pre-CU Backup
# Backup all *.config files.
# Backup all supported OWA customization files:
# https://docs.microsoft.com/en-us/Exchange/clients/outlook-on-the-web/customize-outlook-on-the-web?view=exchserver-2016
# https://docs.microsoft.com/en-us/Exchange/clients/outlook-on-the-web/customize-outlook-on-the-web?view=exchserver-2019
$BackupLocation = "$HOME\Desktop\Exchange_pre-CU_Backup\"
$ExInstallRoot = 'C:\Program Files\Microsoft\Exchange Server\v15\'
$OwaAuthDir = '\FrontEnd\HttpProxy\owa\auth\'
$OwaPremDir = '\ClientAccess\Owa\prem\'