首页 > 系统相关 >PowerShell 保存凭据并转换成字符

PowerShell 保存凭据并转换成字符

时间:2023-03-10 16:32:48浏览次数:34  
标签:转换成 字符 凭据 System InteropServices psCred Runtime PowerShell

将字符保存成凭据

$userName = "admin"
$password = ConvertTo-SecureString "123" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential -ArgumentList ($userName, $password)

将凭据转换成字符

$bStr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($psCred.Password)
System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bStr)
123



Loading

Done

标签:转换成,字符,凭据,System,InteropServices,psCred,Runtime,PowerShell
From: https://blog.51cto.com/xingjia/6113344

相关文章