Get-Credential[[-Credential] <PSCredential>] [<CommonParameters>] PowerShell复制 Get-Credential[-Message <String>] [[-UserName] <String>] [-Title <String>] [<CommonParameters>] 说明 Get-Credentialcmdlet 为指定的用户名
作为使用“以管理员身份运行”来运行脚本的替代方法,可改为使用脚本提示来获取凭据。 许多 Windows PowerShell cmdlet 允许提供备用凭据集。 这样,脚本获取的凭据就可用于运行脚本中的各个命令。 可以使用“Get-Credential”提示获取凭据。 使用“Get-Credential”cmdlet 的语法是: ...
创建凭据对象的第一种方法是使用 PowerShell cmdlet Get-Credential。 在未使用参数的情况下运行它时,系统会提示你输入用户名和密码。 你也可以使用一些可选参数来调用此 cmdlet。 若要预先指定域名和用户名,可以使用“凭据”或“用户名”参数。 使用“用户名”参数时,你还需要提供“邮件”值。 以下代码演示...
Get-Credential [-credential]PSCredential[CommonParameters] Get-Credential [[-UserName]String] -MessageStringKey -credential A user name e.g."User01" or "Domain01\User01" When you submit the command, you are prompted for a password. Starting in Windows PowerShell 3.0, if you enter a user na...
PowerShell中Get-Credential不提示输入密码的方法 因为我很多时候在工作组模式下执行操作,所以远程管理其它主机时,必须要输入凭证信息。一般都会用到Get-Credential来弹出提示框而输入密码。 比如: $c=Get-Credential -Credential DBA_User Get-WmiObject -Credential$c-Class Win32_LogicalDisk -ComputerName 10.0.0.10...
-Credential <PSCredential> 指定凭据的用户名,例如“User01”或“Domain01\User01”。参数名(“Credential”)为可选项。 提交该命令后,系统将提示您输入密码。 如果您输入不带域的用户名,Get-Credential 会在名称前插入一个反斜杠。 如果省略此参数,则将提示您输入用户名和密码。
Additional Notes You can use the PSCredential object that Get-Credential creates in cmdlets that request user authentication, such as those with a Credential* parameter. By default, the authentication prompt appears in a dialog box. To display the authentication prompt at the command line, add the...
$Cred=Get-Credential 与名为 dc01 的域控制器建立一对一 PowerShell 远程处理会话。 PowerShell Enter-PSSession-ComputerNamedc01-Credential$Cred 请注意,PowerShell 提示符前面有[dc01]。 此前缀指示你正在与名为 dc01 的远程计算机进行交互式会话。 现在运行的任何命令在 dc01 上执行,而不是本地计算机。
Get-Credential Get-ExecutionPolicy 获取-Pfx证书 New-FileCatalog Protect-CmsMessage Set-Acl Set-AuthenticodeSignature Set-ExecutionPolicy Test-FileCatalog Unprotect-CmsMessage Microsoft.PowerShell.Utility Microsoft.WSMan.Management PSDiagnostics PSReadLine ...
Summary You can see that creating aPSCredentialobject without using theGet-Credentialcmdlet isn’t too bad at all. In fact, the only task preventing this from being a PowerShell one-liner is just creating the secure string!