This post was most recently updated on January 30th, 2024.8 min read.
In this post, I’ll try to archive everything that you need to download and install to get commandlets like Connect-MsolService working. I’ve had to do it a couple of times when changing laptops, so it’s good to document them somewhere! :)
So, when would you need to follow this guide and install the modules described here? Mostly this comes to play, when you’re switching machines, try to run the SharePoint Online Management shell but it doesn’t even exist on the machine, or it does exist but you get random errors like this:
The term ‘Connect-MsolService’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
The following guide should help you out! I’ll try to keep it updated as things change.
Prerequisites to get Azure AD commandlets (like MSOnline/MSOL and AzureAD) to work
Depending on your use case, you might not always need all of these – but these are the ones I’ve had to recently install (on Windows 10), so these are the ones I’m going to document :)
Time needed: 15 minutes
How to install the prerequisites for AzureAD and related commandlets?
- (Optional) Install Microsoft Online Services Sign-In Assistant for IT Professionals RTW
(Only required for MSOnline)
- (Optional) Install SharePoint Online Management Shell
You can download it from here:
(Or you can actually just use Windows PowerShell if you want to – just see the next step on how to install the correct module!)
- Install MSOnline module – Option 1
Windows Azure Active Directory Module for Windows PowerShell – also known as Azure AD PowerShell module v1, or MSOnline, and probably a number of other names as well!
Run this on PowerShell:
Then hit “y” a couple of times and you should be good!
Note, that this is essentially a legacy module now… But AzureAD commandlet story is confusing, to say the least, and you might end up needing these as well.
- Install AzureAD module – Option 2
Windows Azure Active Directory Module for Windows PowerShell (v2 – also simply known as AzureAD cmdlets)
Verify, that you have .NET Framework 4.5 or above, or download it from here.
Run this in your PowerShell window:
- (Optional) – install AzureRM
If you also need Azure Remote Management (AzureRM) cmdlets (I always do!), run this in an elevated PowerShell:
# Install the Azure Resource Manager modules from the PowerShell Gallery
Now, to run cmdlets like “Connect-MsolService”, just start SharePoint Online Management Shell (or Windows PowerShell).
Welp – I’m still having issues! What do?
If using the modules still fail, you might be running 64b PowerShell but installed the first cmdlets for 32b, or the other way around. In that case, you can just start the right version of PowerShell by finding it from your directory structure, 32b at least can be launched with the MSOnline imported with the following commands:
cd C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "Import-Module MSOnline"
You might need to use a specific version & architecture of PowerShell to run certain scripts because the modules are installed separately between different versions. More information is available right here below:
So which commandlets does this apply to?
These are the commandlets that should start working. They are here for your further reference:See all the AzureActiveDirectory/MSOnline Cmdlets (v1) by clicking on this text!
Adds a member to an administrative unit.
Adds a security group from a partner tenant to a Role in this tenant.
Adds a member to an existing security group.
Adds a member to an administrator role.
Adds a member to an administrative unit-scoped role.
Verifies a custom domain.
Confirms ownership of an unmanaged tenant.
Initiates a connection to Azure Active Directory.
Converts the domain from using standard authentication to using single sign-on.
Converts the domain from using single sign-on (also known as identity federation) to using standard authentication.
Updates a user in a domain that was recently converted from single sign-on.
Disables a device object in Azure Active Directory.
Enables a device object in Azure Active Directory.
Returns all the SKUs for a company.
Retrieves administrative units from Azure AD.
Gets members of an administrative unit.
Gets all directory settings object associated with tenant or group/user/service principal/application/device.
Gets all the directory setting templates that a tenant owns.
Get the current allowed data locations of a company from Azure Active Directory.
Retrieves company-level information.
Gets contacts from Azure Active Directory.
Gets the Azure Active Directory device registration service settings.
Gets an individual device, or a list of devices.
Gets the directory synchronization settings.
Gets the status of identity synchronization features for a tenant.
Checks for objects with synchronization provisioning errors in a tenant.
Retrieves a domain Microsoft Azure Active Directory.
Gets key settings for a federated domain.
Gets DNS records necessary to verify a domain.
Displays the properties of the Active Directory Federation Services 2.0 server and Microsoft Online.
Retrieves a group from Microsoft Azure Active Directory.
Retrieves all members of the specified group.
Gets a list of contracts for a partner.
Retrieves company-level information for partners.
Gets the current password policy for a tenant or a domain.
Gets administrator roles.
Gets members of a role.
Gets members of a role who are granted that role over an administrative unit.
Retrieves a service principal or list of service principals from Microsoft Azure Active Directory.
Gets credentials associated with a service principal.
Gets a directory setting.
Gets a directory setting template.
Gets users from Azure Active Directory.
Gets users based on strong authentication type.
Retrieves a list of roles that the specified user is a member of.
Adds a new administrative unit to Azure Active Directory.
Add a domain to Azure Active Directory.
Adds a new single sign-on domain to Microsoft Online Services and establishes the relying party trust.
Adds a new group to the Azure Active Directory.
Creates a License Options object.
Adds a service principal to Azure Active Directory.
Creates a service principal address.
Add a credential key to a service principal.
Creates a directory setting.
Creates a user in Azure Active Directory.
Creates a well-known group.
Retries the provisioning of a contact object in Azure Active Directory.
Retries the provisioning of a group object in Azure Active Directory.
Retries the provisioning of a user object in Azure Active Directory.
Deletes an administrative unit from Azure Active Directory.
Removes a member from an administrative unit.
Removes a password for an application.
Removes a contact from Azure Active Directory.
Remove a device object from Azure Active Directory.
Removes a domain from Azure Active Directory.
Removes a single sign-on domain from the domains in Microsoft Online.
Removes a security group from a partner tenant.
Removes a group from Azure Active Directory.
Removes a member from a security group.
Removes a member from an administrator role.
Removes a user from an administrative unit-scoped role.
Removes a service principal from Azure Active Directory.
Removes a credential key from a service principal.
Removes a directory setting.
Removes a user from Microsoft Azure Active Directory.
Resets the strong authentication method by using a user principal name.
Restores a deleted user.
Sets the context and credentials to connect to Microsoft Online and to the Active Directory Federation Services 2.0 server.
Updates the properties of an administrative unit.
Sets an allowed data location for a service type for a company in Azure Active Directory.
Sets company-level contact information.
Enables the multinational feature for a service type for a company with Azure Active Directory.
This cmdlet is not in use by any online service, so please consider it deprecated.
Sets company-level security and compliance contact preferences.
Sets company-level configuration settings.
Sets the Azure Active Directory device registration service settings.
Modifies the directory synchronization settings.
Turns directory synchronization on or off for a company.
Sets identity synchronization features for a tenant.
Modifies settings of a domain.
Changes the authentication type of the domain.
Updates settings for a federated domain.
Updates a security group.
Sets company information for partners.
Updates the password policy of a specified domain or tenant.
Updates a service principal in Microsoft Azure Active Directory.
Updates a directory setting in Azure Active Directory.
Modifies a user in Azure Active Directory.
Updates the license assignment for a user.
Resets the password for a user.
Changes the user ID for a user.
Updates the settings in both the Active Directory Federation Services 2.0 server and Microsoft Online.
See all the Azure AD v2 cmdlets by clicking on this text!
Adds an existing Office 365 user or an Office 365 security group to a SharePoint group.
Connects a SharePoint Online global administrator to a SharePoint Online connection (the SharePoint Online Administration Center). This cmdlet must be run before any other SharePoint Online cmdlets can run.
Disconnects from a SharePoint Online service.
Returns application errors.
Returns all installed applications.
Returns all deleted site collections that are in the Recycle Bin.
Returns external users that are located in the tenant’s folder based on specified criteria.
Returns one or more site collections.
Returns all the groups on the specified site collection.
Returns SharePoint Online organization properties.
Retrieves SharePoint Online company logs.
Returns the time when the SharePoint Online organization logs are collected.
Returns the current tenant configuration status.
Returns the SharePoint Online user or security group accounts that match given search criteria.
Shows all site templates that match the given identity.
Creates a new SharePoint Online site collection for the current company.
Creates a new group in a SharePoint Online site collection.
Removes a SharePoint Online deleted site collection from the Recycle Bin.
Permanently removes a collection of external users from the tenant’s folder.
Sends a SharePoint Online site collection to the SharePoint Online Recycle Bin.
Removes a SharePoint Online group from a site collection.
Disables the feature for the tenancy.
Removes a user or a security group from a site collection or a group.
Checks and repairs the specified site collection and its contents.
Requests to create a copy of an existing site collection for the purposes of validating the effects of upgrade without affecting the original site.
Restores a SharePoint Online deleted site collection from the Recycle Bin.
Sets or updates the values of one or more properties for a site collection.
Updates the SharePoint Online owner and permission level on a group inside a site collection.
Sets properties on the SharePoint Online organization.
Enables the tenancy and sets the domain GUIDs.
Configures properties on an existing user.
Tests a SharePoint Online site collection.
Starts the upgrade process on a site collection.
- How to fix catastrophic mouse/touch device input lag on Windows 10? - January 23, 2024
- How to update RAM on Synology DS423+? - January 16, 2024
- How to work around Docker failing to access WSL on Windows? - January 9, 2024