The following code checks if someone using a function; has entered a saved PScredential, if the function needs to prompt the user for a password, or just uses the users current account. Is there an easier way?
Write-Verbose "Checking Credential Param"
if ($Credential.Count -ne 0)
{
if ($Credential.ToString() -contains 'System.Management.Automation.PSCredential')
{
$PSCredential = $Credential
}
else
{
Write-Verbose "Getting Credential"
$PSCredential = (Get-Credential -Credential $Credential)
}
}