😎
Docs
  • Tamm - Docs
  • Azure
    • Sentinel KQL Samples
    • Managed Identities
    • Deploy Sentinel with Terraform
  • Docker
    • Allow standard user to interact with Docker
    • Install Docker
    • Installing and working with Traefik
    • Installing specific version of Docker
    • Deploy Guacamole
    • Traefik geoblock
    • Unpoller Prometheus UCG Ultra
  • HomeAssistant
    • HAOS install on Proxmox
    • Zigbee2MQTT
    • HAOS Reverse Proxy
    • ZBDongle-E
  • Kali
    • Enable RDP
  • Kubernetes
    • Cert manager with Cloudflare
    • On prem loadbalancer metallb
    • Nginx ingress
    • Cloudinit Rancher ubuntu
    • Rancher Ubuntu 18.04 node template
    • Velero with minio backend
    • vsphere pvc (in-tree)
    • Velero cheat sheet
    • nginx annotations examples
  • Linux
    • Expand lvm disk vmware
    • Expand lvm disk fresh install
    • Disk usage
    • flush-dns
    • Netplan config example
    • Add user in photon OS
    • SSH-Keys
    • Set timezone
    • sudo nopasswd
    • Add custom alias
    • Rocky Linux commands
  • macOS
    • Uninstall System extensions
    • 1Password Github setup
  • Microsoft 365
    • Powershell Cheat sheet
  • Portainer
    • Install Portainer
    • Add docker node
  • Powershell
    • GenericList example
    • Mixed stuff n things
    • Synopsis Template
    • Powershell Oh-my-posh
    • Powershell Sync Profile
    • Cleanup and install MS Graph module
  • Proxmox
    • Disable No Subscription notification
    • Import from vmware error
    • Proxmox commands
    • Proxmox on Intel NUC
    • Proxmox E1000
  • Terraform
    • Getting started
    • Deploy Sentinel
  • Unifi
    • Unifi Network App (migration)
    • Slow vlan throughput
    • interface-explanation
  • Windows
    • Network settings access denied
    • Windows GVLK Keys
    • Windows Server 2025
Powered by GitBook
On this page
  • Powershell Cheat sheet
  • List all mailboxes with a forwardingaddress set
  • Get MFA status
  • Teamsgroup export with membercount, owners, whencreated etc
  • List all users and the assigned plans including when it was assigned. Export to CSV
  • List available Account SKUIDs (licenses)
  • List all services enabled for a user with a specific license
  • Re-enable services for an account (all)
  • Convert GUID to ImmuteableId
  • GUID -> ImmuteableId
  • ImmutableId -> GUID
  • Installing the module
  • Interactive Connection
  • Interactive login with limited scope
  • Non interactive with certificate
  • Starting the migrate from the old modules
  • Searching user by UserPrincipalName

Was this helpful?

  1. Microsoft 365

Powershell Cheat sheet

Powershell Cheat sheet

List all mailboxes with a forwardingaddress set

Get-Mailbox | Where-Object {$_.ForwardingSMTPAddress -ne $null} | Select-Object DisplayName,PrimarySMTPAddress,ForwardingSMTPAddress,Whencreated

Get MFA status

Get-MsolUser -all | Select-Object DisplayName,UserPrincipalName,@{N="MFA Status"; E={ if( $_.StrongAuthenticationRequirements.State -ne $null){ $_.StrongAuthenticationRequirements.State} else { "Disabled"}}}

Teamsgroup export with membercount, owners, whencreated etc

Write-Output "DisplayName;Address;Owner;Members;WhenCreated;WhenChanged" | Out-File C:\temp\groups.csv
$groups = Get-UnifiedGroup 
foreach($group in $groups)
    {
        $owner = (Get-UnifiedGroupLinks "$($group.DisplayName)" -LinkType Owner).Name -join "|"
        $memberCount = (Get-UnifiedGroupLinks "$($group.DisplayName)" -LinkType member).count
        "$($group.DisplayName)" + ";" + "$($group.PrimarySMTPAddress)" + ";" + $owner + ";" + $memberCount + ";" + "$($group.WhenCreated)" + ";" + "$($group.WhenChanged)" | out-file C:\temp\groups.csv -Append
    }

List all users and the assigned plans including when it was assigned. Export to CSV

Get-AzureADUser | Select-Object displayName -ExpandProperty assignedplans | Export-Csv C:\slask\test2.csv -NoTypeInformation -Encoding UTF8

Or you can match one serviceplan from https://docs.microsoft.com/en-us/azure/active-directory/enterprise-users/licensing-service-plan-reference

Get-AzureADUser | Where-Object {$_.AssignedPlans.ServicePlanId -match "d5156635-0704-4f66-8803-93258f8b2678"} | Select-Object displayName -ExpandProperty assignedplans | Where-Object {$_.Serviceplanid -match "d5156635-0704-4f66-8803-93258f8b2678"} | Export-Csv C:\slask\test.csv -NoTypeInformationCheck when licenses were assigned (actually when the service was assigned)

List available Account SKUIDs (licenses)

Get-MsolAccountSku 

List all services enabled for a user with a specific license

((Get-MsolUser -UserPrincipalName "user@domain.com").Licenses | Where-Object {$_.AccountSkuId -match "<AccountSku>"}).ServiceStatus

Re-enable services for an account (all)

$licenseObject = New-MsolLicenseOptions -AccountSkuId "<AccountSku>" 
Set-MsolUserLicense -UserPrincipalName "user@domain.com" -LicenseOptions $licenseObject 

Convert GUID to ImmuteableId

And vice versa...

GUID -> ImmuteableId

[Convert]::ToBase64String([guid]::New("87475e6b-319f-431e-a283-cbba08afb1ee").ToByteArray())

ImmutableId -> GUID

[Guid]([Convert]::FromBase64String("a15Hh58xHkOig8u6CK+x7g=="))

Installing the module

Install-Module PowershellGet -Force
Install-Module Microsoft.Graph

Interactive Connection

This will open up your default browser and ask you to sign in. This will grant permission of the user

Connect-MgGraph

Interactive login with limited scope

For example, only requesting permissions for User.Read.All

Connect-MgGraph -Scopes User.Read.All

Non interactive with certificate


Starting the migrate from the old modules

Finding the right command

Finding the right command based on old cmdlet

Finding the right command based on URL from the Api

Searching user by UserPrincipalName

Get-Mguser -Search "userprincipalname:user@domain.com" -ConsistencyLevel eventual
Previous1Password Github setupNextInstall Portainer

Last updated 1 year ago

Was this helpful?