This post was last updated on October 4, 2022.
8 reading minute.
In this post, I will try to archive everything you need to download and install to use commands likeConnect-MsolServiceTo work. I had to do this a few times when switching laptops, so it's good to document them somewhere! :)
So when do you need to follow this guide and install the modules described here? Most of the time this comes into play when you switch computers, you try to run the SharePoint Online Management Shell but it doesn't even exist on the computer, or it exists but you get random errors like this:
The following guide should help you! I'll try to keep you updated as things change.
Depending on your use case, you may not always need all of these, but these are the ones I had to install recently (on Windows 10), so I'll document them :)
Now, to run cmdlets like Connect-MsolService, simply start the SharePoint Online Management Shell (or Windows PowerShell).
If using the modules still fails, you may be running PowerShell 64b but have the initial 32b cmdlets installed, or vice versa. In this case, you can simply start the correct version of PowerShell by looking for it in your directory structure. 32b can at least be started with imported MSOnline with the following commands:
You may need to use a specific version and architecture of PowerShell to run certain scripts because modules are installed separately between different versions. You can find more information here below:
These are the commands that should work. They are here for your future reference:
See all AzureActiveDirectory/MSOnline (v1) cmdlets by clicking this text.
Adds a member to an administrative unit.
Adds a security group from a tenant associated with a role in that tenant.
Adds a member to an existing security group.
Add a member to an administrator role.
Adds a member to a role at the administrative unit scope.
Verify a custom domain.
Confirm ownership of a non-managed tenant.
Starts a connection to Azure Active Directory.
Converts the domain from using basic authentication to using single sign-on.
Converts the domain from using single sign-on (also known as identity federation) to using basic authentication.
Upgrades a user in a domain that was recently converted from single sign-on.
Disables a device object in Azure Active Directory.
Activates a device object in Azure Active Directory.
Returns all SKUs for a company.
Gets administrative units from Azure AD.
Gets the members of an administrative unit.
Gets all directory configuration objects associated with the tenant or group/user/service principal/application/device.
Retrieves all directory configuration templates owned by a tenant.
Retrieve a company's current allowed data locations from Azure Active Directory.
Retrieves information at the company level.
Retrieves contacts from Azure Active Directory.
Retrieves the configuration of the Azure Active Directory device registration service.
Gets a single device or a list of devices.
Gets the directory synchronization settings.
Gets the status of the identity synchronization functions for a tenant.
Searches for objects with synchronization provisioning failures in a tenant.
Gets a domain from Microsoft Azure Active Directory.
Gets the key configuration for a federated domain.
Retrieves the DNS records needed to verify a domain.
Displays the server properties for Active Directory Federation Services 2.0 and Microsoft Online.
Gets a Microsoft Azure Active Directory group.
Gets 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 domain.
Gets administrator roles.
Gets the members of a role.
Gets the members of a role who have been granted that role through an administrative entity.
Gets a service principal or a list of service principals from Microsoft Azure Active Directory.
Gets the credentials associated with a service principal.
Gets a directory configuration.
Gets a directory configuration template.
You get subscriptions.
Retrieves users from Azure Active Directory.
Gets users based on a strong authentication type.
Gets a list of roles to which the specified user belongs.
Adds a new administrative unit to Azure Active Directory.
Add a domain to Azure Active Directory.
Adds a new SSO domain to Microsoft Online Services and establishes the relying party trust.
Add a new group to Azure Active Directory.
Creates a license option object.
Add a service principal to Azure Active Directory.
Create a primary service address.
Add a credential key to a service principal.
New Msol configuration
Create a directory configuration.
Create a user in Azure Active Directory.
Create a known group.
Reprovision a contact object in Azure Active Directory.
Repeat provisioning of a group object in Azure Active Directory.
Repeat provisioning of a user object in Azure Active Directory.
Deletes an administrative unit from Azure Active Directory.
Removes a member from an administrative unit.
Remove a password for an app.
Delete a contact from Azure Active Directory.
Remove a device object from Azure Active Directory.
Removes a domain from Azure Active Directory.
Removes an SSO domain from domains in Microsoft Online.
Removes a security group from an associated tenant.
Removes a group from Azure Active Directory.
Removes a member from a security group.
Remove a member from an admin role.
Removes a user from a role at the administrative unit scope.
Removes a service principal from Azure Active Directory.
Removes a credential key from a service principal.
Deletes a directory configuration.
Deletes a user from Microsoft Azure Active Directory.
Resets the strong authentication method using a user principal name.
Restores a deleted user.
Sets the context and credentials to connect to Microsoft Online and the Active Directory Federation Services 2.0 server.
Updates the properties of an administrative entity.
Sets an allowed data location for a service type for an organization in Azure Active Directory.
Establishes contact information at the company level.
Enables multinational capability for a service type for a company using Azure Active Directory.
No online service uses this cmdlet, so consider it deprecated.
Set contact preferences for enterprise-level security and compliance.
Sets business-level configuration settings.
Configures the Azure Active Directory device registration service settings.
Change directory synchronization settings.
Turn directory synchronization on or off for a company.
Sets identity synchronization capabilities for a tenant.
Change the settings of a domain.
Change the authentication type of the domain.
Updates the configuration of a federated domain.
Updates a security group.
Sets the company information for partners.
Updates the password policy for a specified domain or tenant.
Updates a service principal in Microsoft Azure Active Directory.
Updates a directory configuration in Azure Active Directory.
Modifies a user in Azure Active Directory.
Updates the license assignment for a user.
Resets a user's password.
Changes the user ID of a user.
Updates the configuration on both the Active Directory Federation Services 2.0 server and Microsoft Online.
Add an existing Office 365 user or Office 365 security group to a SharePoint group.
Connects a SharePoint Online global administrator to a SharePoint Online connection (the SharePoint Online admin center). This cmdlet must be run before any other SharePoint Online cmdlets can be run.
You are disconnected from a SharePoint Online service.
Returns application errors.
Returns all installed applications.
Returns all deleted site collections that are in the recycle bin.
Returns the external users located in the tenant's folder based on the specified criteria.
Returns one or more site collections.
Returns all groups in the specified site collection.
Returns the SharePoint Online organization properties.
Retrieves company records from SharePoint Online.
Returns the time that the SharePoint Online organization logs were collected.
Returns the current configuration state of the tenant.
Returns the SharePoint Online user or security group accounts that match the specified search criteria.
Lists all site templates that match the specified identity.
Creates a new SharePoint Online site collection for the current company.
Creates a new group in a SharePoint Online site collection.
Removes a deleted SharePoint Online site collection from the recycle bin.
Permanently deletes a collection of external users from the tenants folder.
Sends a SharePoint Online site collection to the SharePoint Online Recycle Bin.
Pay off SPOSiteGroup
Removes a SharePoint Online group from a site collection.
Disables the feature for the tenant.
Removes a user or security group from a site collection or group.
Checks and repairs the specified site collection and its contents.
Requirements to create a copy of an existing site collection in order to verify the impact of the update without affecting the original site.
Restores a deleted SharePoint Online 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 of a group within a site collection.
Sets properties for the SharePoint Online organization.
Activates the tenant and sets the domain GUIDs.
Set properties for an existing user.
Test a SharePoint Online site collection.
Starts the upgrade process for a site collection.
To connect to the Azure Active Directory Module for Windows PowerShell or MSOnline module, use the Connect-MsolService cmdlet and supply the $M365credentials variable.What commands can you use to find Windows PowerShell cmdlets for managing Active Directory groups? ›
Use the cmdlet Get-Command -Module ActiveDirectory to display all the cmdlets that can be used to manage Active Directory. The Get-Module -ListAvailable command displays all the modules. This allows you to see the names of other modules and use Get-Command to get their cmdlets (Figure 4).How do I install MSOnline PowerShell module for Azure Active Directory? ›
Open an elevated Windows PowerShell command prompt (run Windows PowerShell as an administrator). Run the Install-Module MSOnline command. If you're prompted to install the NuGet provider, type Y and press Enter. If you're prompted to install the module from PSGallery, type Y and press Enter.Why is connect MsolService not working? ›
What does this Connect-MsolService error mean? This error means that you do not have the Connect-MSonline module loaded within your PowerShell session or the module is not installed. If you have installed the module in the past, it may be corrupt and require re-installation.How do I use cmdlet in PowerShell? ›
- To declare the class as a cmdlet, use the Cmdlet attribute. ...
- Specify the name of the class.
- Specify that the cmdlet derives from either of the following classes: ...
- To define the parameters for the cmdlet, use the Parameter attribute. ...
- Override the input processing method that processes the input.
Connecting to the AD drive
Type Import-Module ActiveDirectory in the PowerShell window and press Enter. Now we need to set the working location to the AD drive. Type Set-Location AD: and press Enter. Notice that the PowerShell prompt now changes to PS AD: >.
Simply run any cmdlet related to the module. I use Get-AzureADTenantDetail cmdlet to set a variable representing the tenant name, and check for its existence.How do I get a list of cmdlets in PowerShell? ›
Use CommandType or its alias, Type. By default, Get-Command gets all cmdlets, functions, and aliases. The acceptable values for this parameter are: Alias : Gets the aliases of all PowerShell commands.How do I open Active Directory users and Computers using PowerShell? ›
Which would start a new cmd window running under the <admin account> credentials. From there, you could type dsa. msc to start Active Directory running as that <admin account> instead of the account you were logged in as.What is the PowerShell command to list all cmdlets? ›
The PowerShell Get-Command cmdlet is used to get all the commands which are installed on the computer system. This cmdlet includes functions, other cmdlets, aliases, filters, scripts, and applications. We can get only those commands which have been imported into the current session by using the -ListImported parameter.
Run Command in Azure CLI
Open a Bash terminal. Log in to your Azure tenant using the az login command. If necessary, select a default subscription using the az account set command. Use the az vm run-command invoke and specify the --resource-group and --name of the virtual machine.
- Select. ...
- Select Azure Active Directory, and then select Connect directory.
- Select a directory from the dropdown menu, and then select Connect. ...
- Select Sign out. ...
- Confirm that the process is complete.
Azure CLI, Azure PowerShell, and Azure Cloud Shell have overlapping functionality. Each operates differently, and the language is sometimes confused with the environment.Which PowerShell module must be loaded to run get MSOLUser? ›
The Get-MSOLUser command is part of the MSOnline PowerShell module.Which PowerShell cmdlet can be used to install Active Directory Certificate Services? ›
The Install-AdcsCertificationAuthority cmdlet performs installation and configuration of the Active Directory Certificate Services (AD CS) Certification Authority (CA) role service.How do I set up an intune connector in Active Directory? ›
Select Sign In. Enter the Global administrator or Intune administrator role credentials. The user account must have an assigned Intune license. Go to Devices > Windows > Windows enrollment > Intune Connector for Active Directory, and then confirm that the connection status is Active.How do you check if ad Connect is working? ›
First, log in to the portal. Then, go to Azure Active Directory —> Azure AD Connect. Under the Azure AD Connect sync section, you should see the current status of the directory sync.How do I connect to MS teams in PowerShell? ›
To connect to Microsoft Teams using PowerShell, you will need to first install the Microsoft Teams PowerShell module. This module can be installed from the PowerShell Gallery by running the following command: Install-Module -Name MicrosoftTeams.What is the get MsolUser? ›
The Get-MsolUser cmdlet gets an individual user or list of users. Specify the ObjectId or UserPrincipalName parameter to get a specific user.How do I add cmdlets to PowerShell? ›
- Create a module folder that has the same name as the assembly file in which the cmdlets are implemented. ...
- Make sure that the PSModulePath environment variable includes the path to your new module folder. ...
- Copy the cmdlet assembly into the module folder.
- Add a module manifest file ( .
A cmdlet is a single command that participates in the pipeline semantics of PowerShell. This includes binary (C#) cmdlets, advanced script functions, CDXML, and Workflows.What is cmdlet example? ›
Cmdlets are lightweight commands used in the PowerShell environment. Most of the cmdlets in PowerShell use the Verb-Noun format. For example, Get-Command, Update-Help, Start-Service, etc.How do I run an Active Directory command in PowerShell? ›
Type Start PowerShell and press Enter within the Command Prompt window to open a new Windows PowerShell console window. Type Add-WindowsFeature AD-Domain-Services and press Enter to install Active Directory Domain Services.How do I query Active Directory in PowerShell? ›
If the Active Directory Management module is installed in Windows 10/11 or Windows Server 2019/2022, you can also access specific Active Directory (AD) information in PowerShell. The "Get-Command Get-Ad*" command already shows numerous cmdlets that can display information from Active Directory.How do I check if a domain is connected to PowerShell? ›
first command check if a computer is on domain using Get-WmiObject cmdlet. PartofDomain property of given cmdlet is Boolean type and return true or false based on computer domain membership. If computer is on domain, it will returns true else false. Second command, check if computer is on workgroup or not.Which command should I use to connect to Azure PowerShell? ›
To sign in interactively, use the Connect-AzAccount cmdlet. This cmdlet presents an interactive browser based login prompt by default. Use the Get-AzContext cmdlet to store your tenant ID in a variable to be used in the next two sections of this article.Which PowerShell cmdlet authenticates to an Azure account? ›
Description. The Connect-AzAccount cmdlet connects to Azure with an authenticated account for use with cmdlets from the Az PowerShell modules. You can use this authenticated account only with Azure Resource Manager requests.What is the cmdlet to get the list of services? ›
The Get-Service cmdlet gets all the services on the computer and sends the objects down the pipeline.Can PowerShell run cmdlets? ›
PowerShell lets administrators perform administrative tasks on both local and remote Windows systems. Those tasks are performed by using PowerShell cmdlets (command-lets), which are special simple commands, consist of two words — a verb and a noun — executing a simple function.What is the PowerShell format for cmdlets? ›
Utility) - PowerShell. The Format-List cmdlet formats the output of a command as a list of properties in which each property is displayed on a separate line. You can use Format-List to format and display all or selected properties of an object as a list (Format-List -Property *).
Description. The Get-ADUser cmdlet gets a specified user object or performs a search to get multiple user objects. The Identity parameter specifies the Active Directory user to get.What PowerShell cmdlet can be used to add an Active Directory user? ›
The New-ADUser cmdlet creates an Active Directory user. You can set commonly used user property values by using the cmdlet parameters.How do I run Active Directory users and computers as a different user? ›
- Hold 'Shift' and right-click on your browser icon on the Desktop/Windows Start Menu.
- Select 'Run as different user'.
- Enter the login credentials of the user you wish to use.
Over 200 cmdlets can be used in PowerShell.How do I run an Azure command-line script? ›
Subsequent sessions will use Azure CLI in a Bash environment, Select Copy to copy the blocks of code, paste it into the Cloud Shell, and press Enter to run it.How do I connect to Azure command-line? ›
How to sign into the Azure CLI. Before using any Azure CLI commands with a local install, you need to sign in with az login. Run the login command. If the CLI can open your default browser, it will initiate authorization code flow and open the default browser to load an Azure sign-in page.How do I check Azure AD Connect settings? ›
- Sign into the AAD Sync Server with a local admin account that is also part of the SyncAdmins group.
- Open the Azure AD Connect Wizard.
- Click "Configure" on the Welcome screen.
- Select "View Current Configuration"
- View the configurations.
- Click Start, and then click Run.
- In the Open box, type cmd.
- At the command prompt, type the command dsquery user parameter . The parameter specifies the parameter to use. For the list of parameters, see the online help for the d squery user command.
Use the following steps to force a remote synchronization of AD and Azure: Use the Enter-PSSession command to connect to your Azure AD Connect server. Perform a delta synchronization using the Start-ADSyncSyncCycle command. Exit the PSSession to kill the connection to your Azure AD Connect server.Can I use PowerShell instead of command prompt? ›
For those who prefer using Command Prompt, you can opt out of the Windows Logo Key + X change by opening Settings > Personalization > Taskbar, and turning off, Replace Command Prompt with Windows PowerShell in the menu when I right-click the start button or press Windows key+X.
- Download the Azure CLI 2.0 MSI installer here.
- Launch the installer, select the check box to accept the License Agreement terms, and then click Install.
- From a command line (Windows Command Prompt or PowerShell), run the az login command.
The most notable advantage of using PowerShell over the command prompt is PowerShell's extensibility. While you can create tools for both by writing scripts, the command prompt is limited as an interpreter.How do I connect SQL Server management Studio to PowerShell? ›
Use Win + R , on your Windows computer, and type PowerShell to launch a new Windows PowerShell session. SQL Server provides a PowerShell module named SqlServer. You can use the SqlServer module to import the SQL Server components (SQL Server provider and cmdlets) into a PowerShell environment or script.How does Office 365 tenant connect to PowerShell? ›
- Open Powershell as administrator.
- Run command – Set-ExecutionPolicy Remotesigned.
- Type Y for yes.
- Run command – $UserCredential = Get-Credential.
- Sign in with O365 administrator account (firstname.lastname@example.org)
- Run command – Import-PSSession $Session.
- Install kubectl locally using the Install-AzAksKubectl cmdlet: Azure PowerShell Copy. ...
- Configure kubectl to connect to your Kubernetes cluster using the Import-AzAksCredential cmdlet. ...
- Verify the connection to your cluster using the kubectl get command.
- Open up your PowerShell console, PowerShell ISE, or your favorite PowerShell Editor.
- Type the import-module command as follows: Import-Module SQLPS Copy.
- Confirm that the module is loaded by running the following. This should give the name of the module if it is loaded: Get-Module Copy.
Run PowerShell from SQL Server Agent
You can code Windows PowerShell scripts, and then use SQL Server Agent to include the scripts in jobs that run at scheduled times or in response to SQL Server events. Windows PowerShell scripts can be run using either a command prompt job step or a PowerShell job step.
In the New Job Step dialog, type a job Step name. In the Type list, select PowerShell. In the Run as list, select the proxy account with the credentials that the job will use. In the Command box, enter the PowerShell script syntax that will be executed for the job step.How do I get MSOnline module? ›
- Install-Module MSOnline. ...
- Install-PackageProvider NuGet. ...
- $currentPrincipal = New-Object Security. ...
- Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process.
The Get-AzureADTenantDetail cmdlet gets the details of a tenant in Azure Active Directory (AD).
- Install AZ CLI. Ensure you have installed az cli. ...
- Install Kubectl. There are two ways: AZ CLI or manually installing kubectl.exe. ...
- Connect to AKS Cluster. Similar to cloud shell method, just run az aks get-credentials command to connect to your cluster.
Connect to the cluster
To manage a Kubernetes cluster, use the Kubernetes command-line client, kubectl. kubectl is already installed if you use Azure Cloud Shell. Configure kubectl to connect to your Kubernetes cluster using the az aks get-credentials command.
Managing multiple AKS clusters from CLI:
Once you setup another AKS cluster use az aks list -o table command and get the list of clusters. Get the credentials to the new cluster by using the az aks get-credentials command. Now, you can use kubectl config get-contexts to see all AKS clusters you are authenticated to.
- Update to Windows PowerShell 5.1. If you're on Windows 10 version 1607 or higher, you already have PowerShell 5.1 installed.
- Install . NET Framework 4.7. ...
- Run the following command to install the latest PowerShellGet: PowerShell Copy. ...
- Install the Teams PowerShell Module.
The Connect-MicrosoftTeams cmdlet connects to Microsoft Teams with an authenticated account for use with cmdlets from the MicrosoftTeams PowerShell module. After executing this cmdlet, you can disconnect from MicrosoftTeams account using Disconnect-MicrosoftTeams. Note: With versions 4.How do I run a PowerShell team command? ›
- Install the Teams PowerShell module. Launch a PowerShell window and use the following command: PS> Install-Module -Name MicrosoftTeams. ...
- Sign in. ...
- List the available cmdlets.