1 2 3 4 5 6 7 8 9 10 11 12 13 |
Add-Type -AssemblyName System.DirectoryServices.AccountManagement $account = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine, $env:userdomain) # Nombre de usuario $user = Read-Host -Prompt "Introduzca usuario" # Crear password de tipo SecureString $SecurePassword = Read-Host -Prompt "Introduzca password" -AsSecureString # Extraer password de tipo SecureString $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecurePassword) $PlainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) $account.ValidateCredentials($user, $PlainPassword) |