1

I would like to test my Exchange 2010 service from a remote untrusted domain, in an automated script. That means I need to create client credentials and save them, and I can't follow traditional commands to get the creds interactively.

How would I script the following commands to test connectivity using specified credentials?

Test-WebServicesConnectivity 
Test-ActiveSyncConnectivity
Test-OwaConnectivity
Test-ImapConnectivity
Test-PopConnectivity
Test-ECPConnectivity
Test-PowerShellConnectivity 
makerofthings7
  • 8,911
  • 34
  • 121
  • 197

1 Answers1

1

Here's a function I wrote to generate a new credential object:

function New-Credential {
    param(
        [Parameter(Mandatory=$true,ValueFromPipeline=$true)]
        [System.Security.SecureString]$password,
        [string]$user = 'domain\user'
    )
    process {
        New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user, $password
    }
}

You can get the password as a System.SecureString in a number of ways (here's one way), or you can just use the function like this:

$cred = New-Credential -user somedomain\someuser -password ('somepassword' | ConvertTo-SecureString -AsPlainText -force)

Run 'Help ConvertTo-SecureString -Full' for more details on why you need the -asplaintext and -force parameters).

I hope this is what you're looking for.

jbsmith
  • 1,301
  • 7
  • 13