powershell - Windows Powershell 中的 runas /netonly 等价物是什么?
问题描述
是否可以使用不同的 Kerberos 令牌从 Powershell 启动程序以进行网络访问,而不是像您使用的那样启动程序runas /netonly
?
解决方案
当您使用具有该选项的 cmdlet 时,PowerShell 确实具有 RunAs 选项。
例如:
关于您要完成的工作,有几篇文章已经存在了一段时间。当然,这个查询之前已经出现过。
# 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
# 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.
除了分类 Right click shift 之外,在 Powershell 中以不同用户身份运行命令的主要方法有三种。本文将向您展示如何在同一个 Powershell 会话中执行此操作。
这是一个根据需要下载和剖析的脚本。
也可以看看:
Windows 'runas' 命令的一个版本,它接受 PSCredential 而不是提示输入密码。
推荐阅读
- firefox - 如何在 Firefox 中获取 webrtc 抖动缓冲区?
- r - 删除重复出现的文本字符串
- android-studio - Android - Glide 无法加载图片
- android - 使用 Amazon LWA 登录
- scala - 在scala中使用Window计算带有if条件的行
- conda - Conda 解决策略
- python - 如何使用 dask 在并行化任务中填充 DataFrame?
- jsoup - Jsoup 无法正确解析标题标签
- javascript - 如何让浏览器在 Laravel 应用程序中下载更新的 JS 文件
- excel - 如何在 Excel-VBA 中使用用户窗体在 Word 中插入图像