【问题标题】:What is the equivalent of runas /netonly in Windows Powershell?Windows Powershell 中的 runas /netonly 等价物是什么?
【发布时间】:2019-12-10 20:11:04
【问题描述】:

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

【问题讨论】:

    标签: powershell active-directory kerberos powershell-5.0


    【解决方案1】:

    当您使用具有该选项的 cmdlet 时,PowerShell 确实具有 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

    以不同的用户身份运行命令的三种主要方式 Powershell,除了分类右键shift。本文将 在同一个 Powershell 会话中向您展示如何做到这一点。

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

    另见:

    RunAs 1.3

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

    【讨论】:

      猜你喜欢
      • 2023-04-05
      • 2016-07-25
      • 2011-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-23
      相关资源
      最近更新 更多