Skip to content

Instantly share code, notes, and snippets.

@pandieme
pandieme / Set-EntraIdStagingMode.ps1
Created July 4, 2024 18:35
Set Entra ID (Azure AD) Connect Staging Mode with PowerShell
# Get Entra ID Connect global settings
$ConnectSyncSettings = Get-ADSyncGlobalSettings
# See the value for StagingMode
$ConnectSyncSettings.Parameters | Where-Object Name -eq 'Microsoft.Synchronize.StagingMode').Value
# Set the value for staging mode to True
$ConnectSyncSettings.Parameters | Where-Object Name -eq 'Microsoft.Synchronize.StagingMode').Value = $true
# Set the value for staging mode to False
  1. Piano Covers of Pop Songs: https://open.spotify.com/user/henryecker/playlist/4SBOdi7IMfCrYKZqCqtuXA?si=FL1axIJTTTqYWXYqS6QICw

  2. Extreme focus coding music: Primarily EDM with little to no vocals https://open.spotify.com/user/nebosite/playlist/0hy2h4wf2A3JWvMzK48REE?si=KlMRgPm8QfiC6N9Z-A6jAQ

  3. High Energy programming mix: Most songs have vocals but good for brainstorming portions. https://open.spotify.com/user/jhardinee/playlist/022CloUnijfD00ziUEXJ66?si=WCKBLFEbQmmym-0DNgFLRA

  4. Dubstep study: Dubstep with no vocals

@pandieme
pandieme / SslFix.ps1
Last active October 13, 2022 18:41
Bypass SSL certificate validation check when using Invoke-WebRequest or Invoke-RestMethod in Windows PowerShell
if ($PSEdition -eq 'Desktop') {
class TrustAllCertsPolicy : System.Net.ICertificatePolicy {
[bool] CheckValidationResult (
[System.Net.ServicePoint]$srvPoint,
[System.Security.Cryptography.X509Certificates.X509Certificate]$certificate,
[System.Net.WebRequest]$request,
[int]$certificateProblem
) {
return $true
}
@pandieme
pandieme / PlausibleCloudFrontCDK.ts
Last active October 4, 2022 18:38
CloudFront proxy behaviour with AWS CDK
const plausibleIo = new HttpOrigin('plausible.io', {
protocolPolicy: OriginProtocolPolicy.HTTPS_ONLY
});
const distribution = new Distribution(this, "WebsiteDistribution", {
certificate,
defaultRootObject: "index.html",
errorResponses: [
{
function Backup-Path ([System.IO.FileInfo]$Path, [System.IO.FileInfo]$BackupDirectory) {
if (-not ($Directory = Get-Item -Path $Path -ErrorAction SilentlyContinue)) { return Write-Warning "Unable to find directory [$Path]" }
if (-not $BackupDirectory) { $BackupDirectory = $Directory.Parent.FullName }
if (-not (Test-Path -Path $BackupDirectory)) { New-Item -Path $BackupDirectory -ItemType Directory > $null }
$ExistingBackups = Resolve-Path -Path "$(Join-Path -Path $BackupDirectory -ChildPath $($Directory.Name))*" | Where-Object { $_ -notlike $Directory.FullName }
[int]$Count = 1
while ($ExistingBackups -like (Join-Path -Path $BackupDirectory -ChildPath "$($Directory.Name)$("$Count".PadLeft(2, '0'))")) { $Count++ }
@pandieme
pandieme / Get-SystemWmiFilter.ps1
Created July 28, 2022 11:16
Get System WMI Filter in Active Directory. Used in Group Policy WMI Filtering.
function Get-SystemWmiFilter {
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipeline)]
[string]
$Name,
[Parameter(Mandatory)]
[string]
$DomainName
@pandieme
pandieme / Get-OrganizationalUnitBranches.ps1
Created July 27, 2022 12:53
Get the bottom level branches of an Active Directory Organizational Unit
function Get-OrganizationalUnitBranches(
[Microsoft.ActiveDirectory.Management.ADOrganizationalUnit]
$OrganizationalUnit
) {
[array]$Collection = @()
$Children = Get-ADOrganizationalUnit `
-Filter * `
-SearchBase $OrganizationalUnit.DistinguishedName `
-SearchScope OneLevel
function Import-ModuleFunctions(
[Parameter()]
[array]
$Roots = @(
"$PSScriptRoot/public"
"$PSScriptRoot/private"
),
[Parameter()]
[switch]
function Format-Query(
[Parameter(Mandatory)]
[hashtable]
$Table
) {
<#
.SYNOPSIS
Format URI query
.DESCRIPTION
Take a hashtable and format as a URI query string