This guide shows you how to install the Hawk PowerShell module, a community tool that helps Office 365 and Exchange Online administrators investigate security incidents, audit sign-ins, and gather mailbox or tenant data quickly. Before you start, you need Windows PowerShell 5.1 or PowerShell 7 (recommended), an internet connection, and the ability to run PowerShell as an administrator if your execution policy is restricted. You do not need an Office 365 admin role to install the module, but you will need appropriate permissions when you use it later.

What You'll Need

  • Windows 10/11 or Windows Server 2016+ (PowerShell Core works on Linux/macOS too, but this guide focuses on Windows).
  • PowerShell 5.1 or later – check with $PSVersionTable.PSVersion.
  • An internet connection to download from the PowerShell Gallery.
  • Administrator rights on your machine (only if you need to change the execution policy or install for all users).

Step-by-Step

  1. Open PowerShell as Administrator. Right-click the Start button and select “Windows PowerShell (Admin)” or “Terminal (Admin)” if you use Windows Terminal. If you are on a non-Windows system, open a terminal with sudo.
  2. Check your execution policy. Run Get-ExecutionPolicy. If it returns Restricted, you need to allow script execution. Run Set-ExecutionPolicy RemoteSigned -Scope CurrentUser and press Y when prompted. This allows local scripts and signed remote scripts.
  3. Install the Hawk module from the PowerShell Gallery. Run Install-Module -Name Hawk -Scope CurrentUser -Force. The -Scope CurrentUser avoids needing admin rights and installs only for your account. If you prefer to install for all users, omit -Scope and run as administrator.
  4. Confirm the installation. Run Get-Module -ListAvailable Hawk. You should see the module name, version, and path. If you see nothing, the installation did not complete.
  5. Import the module (if needed). In a new PowerShell session, run Import-Module Hawk. In most cases, PowerShell auto-loads the module when you use a command, but importing explicitly is safe.
  6. Verify the commands are available. Run Get-Command -Module Hawk. You should see a list of functions like Get-HawkUser, Search-HawkMailbox, and Get-HawkSignIn. If you see errors, see Troubleshooting below.
  7. Update the module (optional but recommended). Run Update-Module -Name Hawk periodically to get the latest fixes and features.

Common Mistakes

  • Not checking the execution policy first. If you skip step 2, you may see an error like “Hawk is not digitally signed” or “running scripts is disabled.” Fix it by setting the policy to RemoteSigned.
  • Installing without -Scope CurrentUser when you are not an admin. This causes a permission error. Use -Scope CurrentUser unless you have admin rights and want a system-wide install.
  • Using an old PowerShell version. Hawk requires PowerShell 5.1 or later. If you have Windows PowerShell 3.0 or 4.0, the installation will fail. Upgrade to PowerShell 7 from the official Microsoft site.
  • Forgetting to import the module in a new session. If you open a new PowerShell window and try to use a Hawk command, it may not auto-load if the module is not in the default module path. Always run Import-Module Hawk after opening a new session.

Tips

  • Use a dedicated PowerShell profile. Add Import-Module Hawk to your PowerShell profile ($PROFILE) so it loads automatically every time you start PowerShell.
  • Learn the core commands. Start with Get-HawkUser -UserPrincipalName user@domain.com to pull a full report on a user, and Search-HawkMailbox to search mailbox audit logs.
  • Run Get-Help on any command. For example, Get-Help Get-HawkUser -Examples shows real usage examples.
  • Use the -Verbose flag. When you run a Hawk command, adding -Verbose gives detailed progress, which helps when you are troubleshooting.
  • Keep the module updated. Hawk is actively maintained; run Update-Module -Name Hawk every few months.

Troubleshooting

  • “Install-Module : The specified module 'Hawk' was not published in the gallery.” This usually means you have a typo in the module name or you are not connected to the internet. Double-check the spelling and try again.
  • “Cannot find path 'C:\Program Files\WindowsPowerShell\Modules\Hawk' because it does not exist.” This happens when you tried to install without -Scope CurrentUser and lacked admin rights. Re-run the command with -Scope CurrentUser.
  • “The module 'Hawk' could not be loaded because the execution policy is restricted.” Run Set-ExecutionPolicy RemoteSigned -Scope CurrentUser and confirm. Then try importing again.
  • “Import-Module : The specified module 'Hawk' was not loaded because no valid module file was found.” This means the module was not installed correctly. Uninstall and reinstall: Uninstall-Module Hawk then repeat the install steps.
  • Hawk commands fail with authentication errors. Hawk uses your existing Office 365 session. Run Connect-ExchangeOnline or Connect-MsolService (depending on your tenant) before using Hawk. If you use multi-factor authentication, ensure you complete the MFA prompt.
  • “Get-Command -Module Hawk” returns nothing. Make sure you ran Import-Module Hawk in the current session. If it still fails, check the module path with Get-Module -ListAvailable Hawk.

Frequently Asked Questions

Do I need an Office 365 admin account to install Hawk?

No. Installation only requires PowerShell and internet access. However, to use Hawk to query tenant data, you need an account with appropriate permissions (e.g., Global Admin, Security Reader, or Exchange Admin).

Can I install Hawk on macOS or Linux?

Yes, if you have PowerShell 7 installed. The installation steps are the same, but you may need to run Set-ExecutionPolicy with -Scope CurrentUser and use sudo if you want a system-wide install.

What does Hawk actually do?

Hawk provides a set of PowerShell functions that help Office 365 administrators investigate security issues, audit mailbox access, check sign-in logs, and export user or tenant configuration data. It is not a Microsoft official tool, but it is widely used in the community.

Is Hawk safe to use?

Yes, it is open-source and published on the PowerShell Gallery. However, always review the module code if you are concerned, and avoid running it with elevated privileges unless necessary.

How do I uninstall Hawk?

Run Uninstall-Module -Name Hawk. If you installed with -Scope CurrentUser, it only removes it for your user.

Why do I get an error about TLS 1.2?

Older PowerShell versions may default to TLS 1.0. Run [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 before installing, or upgrade to PowerShell 7.