Windows Powershell 中 runas /netonly 的等价物是什么?

What is the equivalent of runas /netonly in Windows Powershell?

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

PowerShell 确实有一个 RunAs 选项,当您使用带有它的 cmdlet 时。

例如:

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

There are three main ways to run a command as a different user in Powershell, besides the classing Right click shift. This article will show you how to do that, within the same Powershell session.

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

另请参阅:

RunAs 1.3

A version of the Windows 'runas' command that accepts a PSCredential instead of prompting for a password.