0

When I run the script below, in a non-elevated powershell window, it prompts for password on the first line, as it should, but then continues to prompt again for the other four service connect logins. When I run the same commands in an elevated window (right-click and Run as Admin), then it works, prompting only for the first and then connecting to the others using $cred. Can I make this work somehow in a non-elevated window?

if($cred -eq $null){$cred = Get-Credential myemail@something.com}
Connect-MsolService -credential $cred
Connect-AzureAD -credential $cred
Connect-Microsoftteams -credential $cred
Connect-ExchangeOnline -credential $cred
BrownInTown
  • 43
  • 1
  • 7
  • Most windows systems will not work with scripts that contain username and password. For security purposes Windows is using the user login credentials. So just use the login credentials which is automatic and then you will not have any issues. – jdweng Apr 19 '23 at 09:46

0 Answers0