4
votes

I'm trying to connect to PowerShell through the script with username and password. When Password begins with space-like passwordherebeginwithspace, Authentication is failed.

Session creation line is as below:

$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $credential -Authentication Basic -AllowRedirection -ErrorAction Stop;

error:

WARNING: Your connection has been redirected to the following URI: "https://ps.outlook.com/PowerShell-LiveID?PSVersion=5.1.17763.771 " New-PSSession : [ps.outlook.com] Connecting to remote server ps.outlook.com failed with the following error message : Access is denied.

1
I assume you are populating the $credential variable with the Get-Credential cmdlet?infosecb
Yes. It works with office 365 login etc. But not on powershellamatuer coder

1 Answers

3
votes

According to the Office 365 Password Policy, cloud only users are not allowed to have a space in the password.

This is something I've encountered in the past where one part of the service will work(such as Outlook) yet another part will fail(like Sharepoint). The requirement isn't always strictly enforced. It can vary depending on what method was used to set the password(web login form vs. admin assigned it using PowerShell).