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.
$credential
variable with theGet-Credential
cmdlet? – infosecb