PowerShell Troubleshooting Toolkit

Purpose: A practical reference for using PowerShell to diagnose, investigate and resolve common Windows and Microsoft 365 problems.

PowerShell can often retrieve information more quickly than navigating through multiple administration portals. It can also expose configuration details and provide administrative capabilities that aren't readily available through the Windows graphical interface.

This guide is intended for support technicians working with Windows devices and Microsoft 365 customer tenants, including environments administered through Microsoft CSP and GDAP.

Important: Before running commands

  • Confirm that you are connected to the correct customer tenant.
  • Check that your account has the required administrative permissions.
  • Prefer read-only diagnostic commands before attempting changes.
  • Be particularly careful with commands that affect multiple users or an entire tenant.
  • Never store customer passwords, access tokens or other credentials in scripts.
  • Record significant administrative changes.
  • Use -WhatIf where supported to preview changes before executing them.

Command classifications

  • Diagnostic: Retrieves information without intentionally changing configuration.
  • Administrative: Changes settings, accounts, permissions or services.
  • System repair: Repairs or modifies the local Windows installation.

Some commands require PowerShell to be run as administrator. Microsoft 365 commands may also require specific delegated permissions, administrative roles and licences.

Everyday Support – Quick Reference

These are the commands I would recommend learning first.

Common support problems and the command that answers them.
ProblemCommand
Check Windows/Entra connectiondsregcmd /status
Check user's identitywhoami /upn
Check Windows timew32tm /query /status
Check DNSResolve-DnsName domain.dk
Test Outlook connectivityTest-NetConnection outlook.office365.com -Port 443
Check installed Office versionsGet-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*
Check Windows errorsGet-WinEvent -LogName Application -MaxEvents 50
Check mailbox existsGet-EXOMailbox user@domain.dk
Check mailbox sizeGet-EXOMailboxStatistics user@domain.dk
Check mailbox permissionsGet-MailboxPermission user@domain.dk
Check hidden inbox rulesGet-InboxRule -Mailbox user@domain.dk -IncludeHidden
Trace an emailGet-MessageTraceV2 -RecipientAddress user@domain.dk
Check user's licenceGet-MgUserLicenseDetail -UserId user@domain.dk
Check tenant licencesGet-MgSubscribedSku
Check sign-in failuresGet-MgAuditLogSignIn -Filter "userPrincipalName eq 'user@domain.dk' and status/errorCode ne 0"
Check domain verificationGet-MgDomain -DomainId domain.dk

Recommended Official Documentation

The following Microsoft documentation should be used as the primary reference when checking command syntax, module requirements and supported procedures.

Internal Support Guidelines

When adding or using commands in MS365 Sherpa, each command should ideally have the following information:

  1. Command: The exact PowerShell command.
  2. Purpose: What the command does.
  3. When to use it: The customer complaint or problem it helps investigate.
  4. Requirements: Module, connection, permissions and administrator privileges.
  5. Risk: Whether the command is diagnostic or changes the environment.
  6. Expected result: What the technician should look for.

The objective is to make PowerShell a practical support tool, not simply a collection of commands.

Golden rule: Diagnose first, change second.