Connect Exchange Online

Roger Roger 4,956 Reputation points
2022-05-03T20:43:43.593+00:00

Hi All

i have a server and from that server i connect to exchange online but the server has a policy that if you are idle for 15 minutes, the session gets logged off.
i dont want to put my password always when i connect to exchange online.
I want to try something like the below but i am not sure. i dont want my password to be in plain text.

i have saved my user account password in c:\temp\pwd.txt

$username = "myuser@Company portal .com"
$password = Get-Content 'c:\temp\pwd.txt' | Convertto-securestring
$usercredentials = new-object -typename System.Management.PSCredential -argumentlist $username, $password
Connect-ExchangeOnline -Credential $usercredentials

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,207 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,367 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,388 questions
{count} votes

0 additional answers

Sort by: Most helpful