Using explicit credentials with PowerShell cmdlets
There are several PowerShell and Exchange Management Shell cmdlets that provide a credential parameter that allows you to use an alternate set of credentials when running a command. You may need to use alternate credentials when making manual remote shell connections, sending e-mail messages, working in cross-forest scenarios, and more. In this recipe, we'll take a look at how you can create a credential object that can be used with commands that support the -Credential
parameter.
How to do it...
To create a credential object, we can use the Get-Credential
cmdlet. In this example, we store the credential object in a variable that can be used by the Get-Mailbox
cmdlet:
$credential = Get-Credential ...
Get Microsoft Exchange Server 2013 PowerShell Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.