lee*_*d00 6 powershell kerberos active-directory powershell-5.0
是否可以像使用启动程序时使用不同的 Kerberos 令牌进行网络访问一样从 Powershell 启动程序runas /netonly?
当您使用具有 RunAs 选项的 cmdlet 时,PowerShell 确实具有该选项。
例如:
有几篇关于您想要实现的目标的文章已经流传了一段时间。当然,这个问题之前已经出现过。
# You can't use 'runas' directly in Powershell. Anyway as you know, Runas will prompt for a password.
# To run a program with different credentials in Powershell is a two-part process:
# 1. Store the password interactively to an encoded text file:
$credential = Get-Credential 'targetDomain\user'
$credential.Password | ConvertFrom-SecureString | Set-Content c:\scripts\password.txt
Run Code Online (Sandbox Code Playgroud)
# The script:
Start-Process powershell.exe -Credential "TestDomain\Me" -NoNewWindow -ArgumentList "Start-Process powershell.exe -Verb runAs"
<#
The following section starts the PowerShell command-line process with Start-Process
prompting for user credentials. You may not need this dependent on UAC settings,
as you might already get an over-the-shoulder prompt for creds during elevation.
#>
Start-Process powershell.exe -Credential "TestDomain\Me"
# The -NoNewWindow parameter re-uses the same PowerShell command window.
Run Code Online (Sandbox Code Playgroud)
除了右键单击 Shift 之外,在 Powershell 中以不同用户身份运行命令的主要方式还有三种。本文将向您展示如何在同一 Powershell 会话中执行此操作。
这是一个可以根据需要下载和剖析的脚本。
也可以看看:
Windows“runas”命令的一个版本,它接受 PSCredential 而不是提示输入密码。
| 归档时间: |
|
| 查看次数: |
8065 次 |
| 最近记录: |