Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 
share|improve this question

1 Answer 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.