Question : Automated Authentication

Is there a way to automatically pass the password in the following powershell command.

Test-OWAConnectivity -url https://mail.yourdomain.com/owa -mailboxcredentials:(Get-Credential domail\user)

Answer : Automated Authentication

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.Automation.PsCredential -ArgumentList "CONTOSO\Mailbox",$password
Test-OwaConnectivity -URL https://owa.contoso.com/owa -MailboxCredential:$login
Random Solutions  
 
programming4us programming4us