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 many 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.
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-Mailbox -Credential $credential