Skip to content

Instantly share code, notes, and snippets.

@win2000b
win2000b / UnHideUsersFromGAL.ps1
Created February 20, 2026 11:31
Goes through CSV and unhides users in Exchange Online
<# ------------------------------------------------------------
UnhideFromGAL_FromExport_WithStatusCsv.ps1
Uses the export CSV from the proxy export (Identity,Type,Value).
Processes UNIQUE identities and sets:
HiddenFromAddressListsEnabled = $false
Writes a status CSV in the same format as the import CSV log:
Identity,Type,Value,Status,Message,Timestamp
@win2000b
win2000b / ImportSMTP.ps1
Created February 20, 2026 11:19
Script to Import SMTP Aliases and X500 into Exchange Online
<# ------------------------------------------------------------
Import_Primary_SMTP_X500_AddMissingOnly_WithStatusCsv.ps1
Reads: Identity,Type,Value
Writes: Identity,Type,Value,Status,Message,Timestamp
ADD MISSING ONLY:
- SMTP (Type=SMTP) -> adds secondary proxy (forces smtp:)
- X500 (Type=X500) -> adds x500:
- PrimarySMTP (Type=PrimarySMTP) -> optionally sets primary (controlled by $ApplyPrimarySMTP)
@win2000b
win2000b / AddUsersToGroup.ps1
Created February 19, 2026 16:39
Add Users to Entra ID Group using Graph API
# Requires: Microsoft.Graph PowerShell module
# Install (once): Install-Module Microsoft.Graph -Scope CurrentUser
$CsvPath = "C:\Temp\users.csv"
$GroupId = "00000000-0000-0000-0000-000000000000" # <-- Security Group ObjectId
# Connect to Microsoft Graph
# You may be prompted to sign in and consent
Connect-MgGraph -Scopes "Group.ReadWrite.All","User.Read.All"
@win2000b
win2000b / DuplicateGroup.ps1
Created January 6, 2026 17:24
Entra ID - Create New Group with Members of Existing
# Connect to Microsoft Graph
Connect-MgGraph -Scopes "Group.ReadWrite.All"
# Add in Entra Group ID of the Existing Group below
$sourceGroupId = "<ExistingGroupObjectId>"
# Fetch ALL members
$members = Get-MgGroupMember -GroupId $sourceGroupId -All
# Create the new Group
@win2000b
win2000b / Disabled365Accounts_ExcludingSharedMailboxes.ps1
Created June 30, 2025 10:18
Find All disabled Users excluding Shared Mailboxes
# Step 1: Connect to Microsoft Graph
Connect-MgGraph -Scopes "User.Read.All"
# Step 2: Get all disabled users from Microsoft Graph
$allUsers = Get-MgUser -All -Property "DisplayName,UserPrincipalName,AccountEnabled,CreatedDateTime"
$disabledUsers = $allUsers | Where-Object { $_.AccountEnabled -eq $false }
# Step 3: Connect to Exchange Online
Connect-ExchangeOnline
@win2000b
win2000b / Get-EntraSubordinates-WithManagerOnly.ps1
Created June 25, 2025 14:59
Find Manager Subordinates and recurse down
# Run with "powershell -ExecutionPolicy Bypass -File .\Get-EntraSubordinates-WithManagerOnly.ps1"
# Connect to Microsoft Graph
Connect-MgGraph -Scopes "User.Read.All", "Directory.Read.All"
# Function to recursively retrieve all subordinates under a manager
function Get-SubordinatesRecursive {
param (
[string]$ManagerId,
[hashtable]$Visited,
@win2000b
win2000b / Detect and Remediate Windows Store.ps1
Created June 20, 2025 09:27
Intune Device Detect and Remediate - Windows Store App
<#
Type : Detection
Job: Detects Microsoft 3D Viewer
Run as: System
Context: 64 Bit
#>
# Replace with part or full name of the app package
$appName = "Microsoft.Microsoft3DViewer"
@win2000b
win2000b / Detect and Remediate.ps1
Last active June 20, 2025 09:26
Intune Device Detect and Remediate - Registry Key
<#
Type: Detection
Job: Detects Registry Key and if present or not
Run as: System
Context: 64 Bit
#>
# Define Varibles
$regPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WinRM\Client"
$regName = "AllowBasic"
@win2000b
win2000b / DisableBasicAuth.ps1
Last active June 20, 2025 09:21
Set Registry Key via Win32 App
# Sample Script for Win32 Application to set a reg key and monitor it.
$regPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WinRM\Client"
$valueName = "AllowBasic"
$desiredValue = 0
# Ensure the registry key exists
if (-not (Test-Path $regPath)) {
New-Item -Path $regPath -Force | Out-Null
}
@win2000b
win2000b / GetTeamsNumbers.ps1
Created April 14, 2022 10:52
Get List of Teams Numbers and export to CSV
# Install the Teams Module within PowerShell
Install-Module MicrosoftTeams
# Connect to Microsoft Teams PowerShell
Connect-MicrosoftTeams
#Get list of Users and export their details to csv
Get-CsOnlineUser -Filter {LineURI -ne $Null} | select DisplayName,LineURI,OnlineVoiceRoutingPolicy | Export-CSV c:\temp\teams.csv -NoTypeInformation