Author: Matthew Dowst

Azure

Easily Switch Between Azure Subscriptions and Tenants

$SubscriptionId = "Your-Subscription-Guid" if($(Get-AzureRmContext).Subscription.SubscriptionId -ne $SubscriptionId){ Set-AzureRmContext -SubscriptionId $SubscriptionId -ErrorAction SilentlyContinue if($(Get-AzureRmContext).Subscription.SubscriptionId -ne $SubscriptionId){ Clear-AzureRMContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue Clear-AzureRmDefault -Force -ErrorAction SilentlyContinue $connect = Add-AzureRmAccount -SubscriptionId $SubscriptionId } }
Active DirectoryGroups

Get the AD Groups for a User with 1 Level of Inheritance

# Get the direct group memberships $UserGroups = Get-ADPrincipalGroupMembership $UserName | Select distinguishedName, GroupCategory, GroupScope, name, objectClass, objectGUID, SamAccountName, SID, @{l='Membership';e={'Direct'}}, @{l='Parent';e={$null}} # Get the group membership 1 level down foreach($group in $UserGroups){ $UserGroups += Get-ADPrincipalGroupMembership -Identity $group.distinguishedName | Select distinguishedName, GroupCategory, GroupScope, name, objectClass, objectGUID, SamAccountName, SID, @{l='Membership';e={'Inherit'}}, @{l='Parent';e={$group.distinguishedName}} } # Display results $UserGroups | FT name, GroupCategory, GroupScope,...