create the password in a text file:
$my_secure_password_string
= convertto-securestring "Exchange12Rocks" -asplaintext -force
$my_encrypted_string = convertfrom-securestring $my_secure_password_string
-key (1..16)
$my_encrypted_string > password.txt
then utilize the text file in a script:
$password = convertto-securestring (get-content password.txt) -key (1..16)
$login = New-Object -TypeName System.Management.Automati
on.PsCrede
ntial -ArgumentList "CONTOSO\Mailbox",$passwor
d
Test-OwaConnectivity -URL
https://owa.contoso.com/owa -MailboxCredential:$login