The error message “A positional parameter cannot be found that accepts argument [user name]” is most likely one of the first errors you’ll encounter when starting up with Office 365 PowerShell’ing:
PS C:\> Get-MsolUser morten@skrubbeltrang.onmicrosoft.com Get-MsolUser : A positional parameter cannot be found that accepts argument 'morten@skrubbeltrang.onmicrosoft.com'. At line:1 char:1 + Get-MsolUser morten@skrubbeltrang.onmicrosoft.com + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-MsolUser], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound, Microsoft.Online.Administration.Automation.GetUser
The fix for this error message is quite simple:
Always use “-UserPrincipalName” as the first argument when running the Get-MSOLUser command:
PS C:\> Get-MsolUser -UserPrincipalName morten@skrubbeltrang.onmicrosoft.com UserPrincipalName DisplayName isLicensed ----------------- ----------- ---------- morten@skrubbeltrang.onmicrosoft.com morten skrubbeltrang True
Alternatively, if you want to search for multiple instances of Azure AD users you can use the SearchString parameter, e.g.:
PS C:\> Get-MsolUser -SearchString "Brahe" UserPrincipalName DisplayName isLicensed ----------------- ----------- ---------- tycho.brahe@skrubbeltrang.onmicrosoft.com Tycho Brahe False tbrahe@skrubbeltrang.onmicrosoft.com Thomas Brahe False
This command will search the DisplayName or EmailAddress for the provided string.
The PowerShell MSOnline Module
The Get-MSOLUser command is part of the MSOnline PowerShell module.
In many cases you can end up with multiple versions of the MSOnline module installed side by side. Troubleshooting which module is being loaded can be quite confusing.
Also, in some cases, the installation of the module itself causes some headache.
If you want to know more about installation and troubleshooting of this module, have a look at this article. It includes a full explanation of the module load order in PowerShell.
Easy Office 365 Management
To skip the need to use the MSOnline PowerShell module entirely you should have a look at Easy365Manager.
Easy365Manager works as an extension to the familiar AD Users & Computers tool. With Easy365Manager you can configure Office 365 licenses and mailboxes using your native on-premises AD user management tool. No need to constantly log in to the AD Azure portal and Exchange Admin Center.
Easy365Manager also enables you to get rid of your on-premises Exchange Server. This allows you to save a lot of time and money in a short time frame.
Download the free and fully functional 30 day trial here.