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.
AzureActiveDirectory-Cmdlets (v1)
Add MsolAdministrativeUnitMember
Adds a member to an administrative unit.
Add MsolForeignGroupToRole
Adds a security group from a tenant associated with a role in that tenant.
Add MsolGroupMember
Adds a member to an existing security group.
Add MsolRoleMember
Add a member to an administrator role.
Add MsolScopedRoleMember
Adds a member to a role at the administrative unit scope.
Confirm-MsolDomain
Verify a custom domain.
Confirmar-MsolEmailVerifiedDomain
Confirm ownership of a non-managed tenant.
Connect-MsolService
Starts a connection to Azure Active Directory.
Convert-MsolDomainToFederated
Converts the domain from using basic authentication to using single sign-on.
Convert-MsolDomainToStandard
Converts the domain from using single sign-on (also known as identity federation) to using basic authentication.
Convert-MsolFederatedUser
Upgrades a user in a domain that was recently converted from single sign-on.
Disable MsolDevice
Disables a device object in Azure Active Directory.
enable-msoldevice
Activates a device object in Azure Active Directory.
Get MsolAccountSku
Returns all SKUs for a company.
Get-MsolAdministrativeUnit
Gets administrative units from Azure AD.
Get-MsolAdministrativeUnitMember
Gets the members of an administrative unit.
Get MsolAllSettings
Gets all directory configuration objects associated with the tenant or group/user/service principal/application/device.
Get-MsolAllSettingTemplate
Retrieves all directory configuration templates owned by a tenant.
Get-MsolCompanyAllowedDataLocation
Retrieve a company's current allowed data locations from Azure Active Directory.
Get-MsolCompanyInformation
Retrieves information at the company level.
Get-MsolContacto
Retrieves contacts from Azure Active Directory.
Get-MsolDeviceRegistrationServicePolicy
Retrieves the configuration of the Azure Active Directory device registration service.
Get MsolDevice
Gets a single device or a list of devices.
Get-MsolDirSyncConfiguration
Gets the directory synchronization settings.
Get-MsolDirSyncFeatures
Gets the status of the identity synchronization functions for a tenant.
Get-MsolDirSyncProvisioningError
Searches for objects with synchronization provisioning failures in a tenant.
Get MsolDomain
Gets a domain from Microsoft Azure Active Directory.
Get-MsolDomainFederationSettings
Gets the key configuration for a federated domain.
Get-MsolDomainVerificationDns
Retrieves the DNS records needed to verify a domain.
Get-MsolFederationProperty
Displays the server properties for Active Directory Federation Services 2.0 and Microsoft Online.
Get-MsolGroup
Gets a Microsoft Azure Active Directory group.
Get-MsolGroupMember
Gets all members of the specified group.
Get-MsolHasObjectsWithDirSyncProvisioningErrors
Get-MsolPartnerContract
Gets a list of contracts for a partner.
Get-MsolPartnerInformation
Retrieves company-level information for partners.
Get-MsolPasswordPolicy
Gets the current password policy for a tenant or domain.
Get MsolRole
Gets administrator roles.
Get MsolRoleMember
Gets the members of a role.
Get-MsolScopedRoleMember
Gets the members of a role who have been granted that role through an administrative entity.
Get-MsolServicePrincipal
Gets a service principal or a list of service principals from Microsoft Azure Active Directory.
Get-MsolServicePrincipalCredential
Gets the credentials associated with a service principal.
Get-MsolSettings
Gets a directory configuration.
Get-MsolSettingTemplate
Gets a directory configuration template.
Get-MsolSubscription
You get subscriptions.
Get-MsolUser
Retrieves users from Azure Active Directory.
Get-MsolUserByStrongAuthentication
Gets users based on a strong authentication type.
Get MsolUserRole
Gets a list of roles to which the specified user belongs.
New-MsolAdministrativeUnit
Adds a new administrative unit to Azure Active Directory.
New-MsolDomain
Add a domain to Azure Active Directory.
New-MsolFederatedDomain
Adds a new SSO domain to Microsoft Online Services and establishes the relying party trust.
New-MsolGroup
Add a new group to Azure Active Directory.
New-MsolLicenseOptions
Creates a license option object.
New-MsolServicePrincipal
Add a service principal to Azure Active Directory.
New-MsolServicePrincipalAddresses
Create a primary service address.
New-MsolServicePrincipalCredential
Add a credential key to a service principal.
New Msol configuration
Create a directory configuration.
New-MsolUser
Create a user in Azure Active Directory.
New-MsolWellKnownGroup
Create a known group.
Redo-MsolProvisionContacto
Reprovision a contact object in Azure Active Directory.
Redo-MsolProvisionGroupRedo-MsolProvisionGroup
Repeat provisioning of a group object in Azure Active Directory.
Ready-MsolProvisionUser
Repeat provisioning of a user object in Azure Active Directory.
Remove-MsolAdministrativeUnit
Deletes an administrative unit from Azure Active Directory.
Remove-MsolAdministrativeUnitMember
Removes a member from an administrative unit.
Remove-MsolApplicationPassword
Remove a password for an app.
Delete-MsolContact
Delete a contact from Azure Active Directory.
Remove MsolDevice
Remove a device object from Azure Active Directory.
Remove MsolDomain
Removes a domain from Azure Active Directory.
Remove MsolFederatedDomain
Removes an SSO domain from domains in Microsoft Online.
Quitar MsolForeignGroupFromRole
Removes a security group from an associated tenant.
Remove MsolGroup
Removes a group from Azure Active Directory.
Remove MsolGroupMember
Removes a member from a security group.
Remove MsolRoleMember
Remove a member from an admin role.
Remove MsolScopedRoleMember
Removes a user from a role at the administrative unit scope.
Remove MsolServicePrincipal
Removes a service principal from Azure Active Directory.
Remove-MsolServicePrincipalCredential
Removes a credential key from a service principal.
Remove MsolSettings
Deletes a directory configuration.
Delete-MsolUser
Deletes a user from Microsoft Azure Active Directory.
Reset MsolStrongAuthenticationMethodByUpn
Resets the strong authentication method using a user principal name.
Restore-MsolUser
Restores a deleted user.
Set MsolADFSContext
Sets the context and credentials to connect to Microsoft Online and the Active Directory Federation Services 2.0 server.
Set-MsolAdministrativeUnit
Updates the properties of an administrative entity.
Establecer-MsolCompanyAllowedDataLocation
Sets an allowed data location for a service type for an organization in Azure Active Directory.
Set-MsolCompanyContactInformation
Establishes contact information at the company level.
Set-MsolCompanyMultiNationalEnabled
Enables multinational capability for a service type for a company using Azure Active Directory.
Set-MsolCompanySecurityComplianceContactInformation
No online service uses this cmdlet, so consider it deprecated.
Set contact preferences for enterprise-level security and compliance.
Set MsolCompanySettings
Sets business-level configuration settings.
Set-MsolDeviceRegistrationServicePolicy
Configures the Azure Active Directory device registration service settings.
Set-MsolDirSyncConfiguration
Change directory synchronization settings.
Set-MsolDirSyncEnabled
Turn directory synchronization on or off for a company.
Set MsolDirSyncFeature
Sets identity synchronization capabilities for a tenant.
Set-MsolDomain
Change the settings of a domain.
Set-MsolDomainAuthentication
Change the authentication type of the domain.
Set-MsolDomainFederationSettings
Updates the configuration of a federated domain.
Set-MsolGroup
Updates a security group.
Set-MsolPartnerInformation
Sets the company information for partners.
Set MsolPasswordPolicy
Updates the password policy for a specified domain or tenant.
Set-MsolServicePrincipal
Updates a service principal in Microsoft Azure Active Directory.
Set-MsolSettings
Updates a directory configuration in Azure Active Directory.
set-msolUser
Modifies a user in Azure Active Directory.
Set-MsolUserLicense
Updates the license assignment for a user.
set-msolUserPassword
Resets a user's password.
Set-MsolUserPrincipalName
Changes the user ID of a user.
Update-MsolFederatedDomain
Updates the configuration on both the Active Directory Federation Services 2.0 server and Microsoft Online.
Azure AD v2 cmdlets in detail
Add-SPOUser
Add an existing Office 365 user or Office 365 security group to a SharePoint group.
Conectar-SPOService
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.
Disconnectar-SPOService
You are disconnected from a SharePoint Online service.
Get-SPOAppErrors
Returns application errors.
Get SPOAppInfo
Returns all installed applications.
Get-SPODeletedSite
Returns all deleted site collections that are in the recycle bin.
Get-SPOExternalUser
Returns the external users located in the tenant's folder based on the specified criteria.
Get SPOSite
Returns one or more site collections.
Get-SPOSiteGroup
Returns all groups in the specified site collection.
Get-SPOTenant
Returns the SharePoint Online organization properties.
Get SPOTenantLogEntry
Retrieves company records from SharePoint Online.
Get-SPOTenantLogLastAvailableTimeInUtc
Returns the time that the SharePoint Online organization logs were collected.
Get-SPOTenantSyncClientRestriction
Returns the current configuration state of the tenant.
Get-SPOUser
Returns the SharePoint Online user or security group accounts that match the specified search criteria.
Get SPOWebTemplate
Lists all site templates that match the specified identity.
Neue-SPOSite
Creates a new SharePoint Online site collection for the current company.
Neue-SPOSiteGroup
Creates a new group in a SharePoint Online site collection.
Remove-SPODeletedSite
Removes a deleted SharePoint Online site collection from the recycle bin.
Remove-SPOExternalUser
Permanently deletes a collection of external users from the tenants folder.
Pay SPOSite
Sends a SharePoint Online site collection to the SharePoint Online Recycle Bin.
Pay off SPOSiteGroup
Removes a SharePoint Online group from a site collection.
Quitar SPOTenantSyncClientRestriction
Disables the feature for the tenant.
Remove-SPOUser
Removes a user or security group from a site collection or group.
Repair-SPOSite
Checks and repairs the specified site collection and its contents.
Request-SPOUpgradeEvaluationSite
Requirements to create a copy of an existing site collection in order to verify the impact of the update without affecting the original site.
Restorar-SPODeletedSite
Restores a deleted SharePoint Online site collection from the recycle bin.
establish-SPOSite
Sets or updates the values of one or more properties for a site collection.
Establish-SPOSiteGroup
Updates the SharePoint Online owner and permission level of a group within a site collection.
Conjunto-SPOTtenant
Sets properties for the SharePoint Online organization.
Establecer SPOTenantSyncClientRestriction
Activates the tenant and sets the domain GUIDs.
Establish-SPOUser
Set properties for an existing user.
Test-SPOSite
Test a SharePoint Online site collection.
Update-SPOSite
Starts the upgrade process for a site collection.
FAQs
What is the PowerShell cmdlet to connect to Azure AD? ›
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.
How do I run a PowerShell script from Azure CLI? ›
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 ( .
Is a cmdlet a command? ›
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 *).
Which parameter is used to get all Active Directory users on a PowerShell cmdlet? ›
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.
How do I install Azure CLI in Windows using PowerShell? ›
- 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 (user@company.com)
- 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).
How do I access AKS cluster from command line? ›
- 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.