Last summer I had a fun time trying to figure out how to use powershell to import users into Office 365. After weeks of grief I got my scripts to work and imported 1200 users into a new O356 environment. It was debatable whether it was quicker than doing it long hand, but I figured that next year (as in NOW) the time spent would be worth it. Wrong!
So here I am now running on Windows 8.1 pro and I'm back at the start.
Import-Module MSOnline is not recognised but this time the Microsoft online service modules seem to be installed. Nothing works and all my PowerShell books and O365 books are out of date after £100's!
Here's what I get and I've tried all I know and failed. I've only got three days to get it done but I've only got 200 users. Its a race! Lets see if PowerShell can waste more of my time than doing it long hand. Will anyone come to PowerShell's rescue?
PS C:\WINDOWS\system32> $LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft. Exchange -ConnectionUri
https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
New-PSSession : A positional parameter cannot be found that accepts argument 'Exchange'.
At line:2 char:12
+ $Session = New-PSSession -ConfigurationName Microsoft. Exchange -ConnectionUri h ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-PSSession], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.NewPSSessionCommand
Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Provide a valid value for
the argument, and then try running the command again.
At line:3 char:18
+ Import-PSSession $Session
+ ~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Import-PSSession], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportPSSessionCommand
PS C:\WINDOWS\system32> Import-Module MSOnline
Import-Module : The specified module 'MSOnline' was not loaded because no valid module file was found in any module
directory.
At line:1 char:1
+ Import-Module MSOnline
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (MSOnline:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
PS C:\WINDOWS\system32>