在Windows Powershell中等效于runas / netonly吗?

问题描述 投票:0回答:1

是否有可能像使用runas /netonly一样从Powershell中使用用于启动程序的Kerberos令牌使用不同的Kerberos令牌来进行网络访问?

powershell active-directory kerberos powershell-5.0
1个回答
2
投票

PowerShell在具有cmdlet的情况下确实具有RunAs选项。

例如:

Start-Process

关于您要完成的工作,已有几篇文章发表了一段时间。当然,此查询以前已经出现过。

RunAS /netony - PowerShell equivalent ?

# 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

Using a PowerShell script to run as a different user & elevate the process.

# 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 a command as a different user in Powershell

有三种主要方法可以在Windows中以其他用户身份运行命令Powershell,除了分类右键单击移位。本文将向您展示如何在同一Powershell会话中执行此操作。

这里是一个脚本,可以根据需要下载和剖析。

另请参见:

RunAs 1.3

Windows'runas'命令的一个版本,接受PSCredential,而不提示输入密码。

© www.soinside.com 2019 - 2024. All rights reserved.