Get user credentials securely in PowerShell

#Get user credentials securely
Try {
	$credentials = Get-Credential "$env:username"
}
Catch {
	$log += "`n- " + $_.Exception.Message
	Output-Result
}

#Get current domain to use for authentication. ADSI = Active Directory
$currentDomain = "LDAP://" + ([ADSI]"").distinguishedName

#Authenticate
$activeDirectoryEntry = New-Object System.DirectoryServices.DirectoryEntry($currentDomain,$credentials.GetNetworkCredential().UserName,$credentials.GetNetworkCredential().Password)
if ($activeDirectoryEntry.name -eq $null)
{
    $log += "`n- Failed to authenticate that username and password."
    Output-Result	
} else {
    $log += "`n- Authentication was successful."
}

#Display Results
$log = "Results:"
function Output-Result {
    [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") > null
    $oReturn=[System.Windows.Forms.Messagebox]::Show($log)
    Break
}