Skip to content

Instantly share code, notes, and snippets.

@chadmando
chadmando / enum-distgroup.ps1
Created February 17, 2025 14:37
Get members of a distribution group and include nested groups
# Code written by Copilot - no guarantees
# Function to get members of a distribution group, including nested groups
function Get-DistributionGroupMembers {
param (
[string]$GroupName
)
ProductName;LicensePartNumber;LicenseSKUID
APP CONNECT IW;SPZA_IW;8f0c5670-4e56-4892-b06d-91c085d7004f
Microsoft 365 Audio Conferencing;MCOMEETADV;0c266dff-15dd-4b49-8397-2bb16070ed52
AZURE ACTIVE DIRECTORY BASIC;AAD_BASIC;2b9c8e7c-319c-43a2-a2a0-48c5c6161de7
AZURE ACTIVE DIRECTORY PREMIUM P1;AAD_PREMIUM;078d2b04-f1bd-4111-bbd4-b4b1b354cef4
AZURE ACTIVE DIRECTORY PREMIUM P2;AAD_PREMIUM_P2;84a661c4-e949-4bd2-a560-ed7766fcaf2b
AZURE INFORMATION PROTECTION PLAN 1;RIGHTSMANAGEMENT;c52ea49f-fe5d-4e95-93ba-1de91d380f89
DYNAMICS 365 CUSTOMER ENGAGEMENT PLAN ENTERPRISE EDITION;DYN365_ENTERPRISE_PLAN1;ea126fc5-a19e-42e2-a731-da9d437bffcf
DYNAMICS 365 FOR CUSTOMER SERVICE ENTERPRISE EDITION;DYN365_ENTERPRISE_CUSTOMER_SERVICE;749742bf-0d37-4158-a120-33567104deeb
DYNAMICS 365 FOR FINANCIALS BUSINESS EDITION;DYN365_FINANCIALS_BUSINESS_SKU;cc13a803-544e-4464-b4e4-6d6169a138fa
Term Description Link(s)
Alias Another email address that people can use to email
App Password An app password is a password that is created within the Azure portal and that allows the user to bypass MFA and continue to use their application.
Alternate email address Required for admins to receive important notifications, or resetting the admin password which cannot be modified by the end users
AuditAdmin
AuditDelegate
Delegate An account with assigned permissions to a mailbox.
Display Name Name that appears in the Address Book & on the TO and From lines on an email.
EAC "Exchange Admin Center"
@chadmando
chadmando / CeilingFan.ps1
Created May 14, 2024 16:22 — forked from dfinke/CeilingFan.ps1
Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
<#
Allow an object to alter its behavior when its internal state changes.
The object will appear to change its class.
The State pattern puts each branch of the conditional in a separate class.
This lets you treat the object's state as an object in its own right
that can vary independently from other objects
#>
@chadmando
chadmando / EnrollIntune.ps1
Created April 5, 2024 19:44
Device Enrollment Script for AAD Joined Machine that were not enrolled in Intune upon setup
# Intially copied from this article https://call4cloud.nl/2020/05/intune-auto-mdm-enrollment-for-devices-already-azure-ad-joined/
# "The Improved One"
# Set MDM Enrollment URL's
$key = 'SYSTEM\CurrentControlSet\Control\CloudDomainJoin\TenantInfo\*'
try{
$keyinfo = Get-Item "HKLM:\$key"
}
catch{
@chadmando
chadmando / ns-u.ps1
Created March 19, 2024 15:15
ns command for UDP connections in powershell
# Full credit for this goes to a SANS ICS diary by Rob Vandenbrink
# https://isc.sans.edu/diary/30532?n
Get-NetUDPEndpoint |
Select-Object LocalAddress,LocalPort,CreationTime,OwningProcess,@{Name="Process";Expression={(Get-Process -Id $_.OwningProcess).ProcessName}} |
Format-Table -auto
@chadmando
chadmando / ns-t.ps1
Created March 19, 2024 15:04
ns command written in powershell to include lifetime of established connections - TCP version
# Full credit for this goes to a SANS ICS diary by Rob Vandenbrink
# https://isc.sans.edu/diary/30532?n
$now = get-date
Get-NetTCPConnection |
select-object LocalAddress,LocalPort,RemoteAddress,RemotePort,State,@{Name="LifetimeSec";Expression={($now-$_.CreationTime).seconds}},OwningProcess, @{Name="Process";Expression={(Get-Process -Id $_.OwningProcess).ProcessName}} |
sort-object -property LifetimeSec |
select-object -last 10 |
ft -auto
@chadmando
chadmando / Get-AzureADPSPermissions.ps1
Created February 21, 2024 04:01 — forked from psignoret/Get-AzureADPSPermissions.ps1
Script to list all delegated permissions and application permissions in Azure AD
<#
.SYNOPSIS
Lists delegated permissions (OAuth2PermissionGrants) and application permissions (AppRoleAssignments).
.PARAMETER DelegatedPermissions
If set, will return delegated permissions. If neither this switch nor the ApplicationPermissions switch is set,
both application and delegated permissions will be returned.
.PARAMETER ApplicationPermissions
If set, will return application permissions. If neither this switch nor the DelegatedPermissions switch is set,
@chadmando
chadmando / winget_pkgs.json
Created September 12, 2023 02:35
Example result of winget export command
{
"$schema" : "https://aka.ms/winget-packages.schema.2.0.json",
"CreationDate" : "2023-09-11T21:26:35.321-00:00",
"Sources" :
[
{
"Packages" :
[
{
"PackageIdentifier" : "Docker.DockerDesktop"
@chadmando
chadmando / searchWingetLogs.ps1
Created August 21, 2023 18:11 — forked from mavaddat/searchWingetLogs.ps1
PowerShell Core function to search Winget (aka Windows Package Manager) logs
#Requires -Version 6.0
<#
.SYNOPSIS
Retrieves recent winget logs and searches them for a pattern, if specified.
.DESCRIPTION
This script parses the Windows Package Manager winget command-line tool log files and allows searching by specifying a pattern or date boundaries.
.PARAMETER Search
The pattern to search for in the log files. If not specified, all log entries are returned.
.PARAMETER AfterDate
The date after which to search for log entries. If not specified, all log entries are returned.