Secure password rejected as bad but thats incorrect Share on Facebook Post on reddit Tweet on Twitter Share on LinkedIn Home › Forums › Scripting › PowerShell › Secure password rejected as bad but thats incorrect Tagged: Office 365 This topic has 1 reply, 2 voices, and was last updated 2 years ago by wullieb1. Viewing 1 post (of 1 total) Author Posts confuseisParticipant Sep 02, 2019 at 2:43 pm #623404 Hi Im doing some work with office 365 Im looking to automate a task Im using below code but getting error on the last line “Connect-Msolservice : Authentication error: Bad username or password. Problem is the password works perfectly everywhere for me dont see why im getting such error so dont know how to troubleshoot. Searched online to no avail so far. $username = “Mickey” $password = “KnownGoodPassword” $securePWD = $password | ConvertToSecureString -AsPlainText -Force $MyCredential = NewObject -typename System.Management.Automation.PSCredential -Argumentlist $username,$securePWD Import-Module MSonline Connect-MSOlService -credential $MyCredential Author Posts Viewing 1 post (of 1 total) You must be logged in to reply to this topic.