![](/img/trans.png)
[英]Running cmd.exe through Start-Process with -Verb RunAs and then automatically running a command as Administrator
[英]Difference between runas.exe and Start-Process -Credential
我正在玩在客戶端網絡上的vpn上設置一些腳本。 此客戶端通常在其網絡上分配ActiveDirectory帳戶,並使用它來管理權限(例如,數據庫)。 好的,這是有道理的。
但這有些令我困惑的事情:
start-process runas.exe "/user:CLIENTDOMAIN\George.Mauer /netonly W:\tools\LINQPad4\LINQPad.exe
查詢密碼並運行正常(我可以訪問數據庫)
但
Start-Process W:\tools\LINQPad4\LINQPad.exe -Credential (Get-Credential)
並在彈出提示符下輸入CLIENTDOMAIN\\George.Mauer
和我的密碼總是會導致錯誤
Start-Process : This command cannot be run due to the error: The user name or password is incorrect.
這些不一樣嗎? runas
和-Credential
之間有什么區別? 第二個問題 - 如何使用CLIENTDOMAIN\\George.Mauer
憑證Start-Job
?
/netonly
以當前用戶身份運行該進程,並且僅與其他憑據建立網絡連接。
Start-Process
將使用其他憑據運行進程(及其所有網絡連接)。 使用Start-Process
無法實現/NETONLY
功能。
您必須p / invoke Win32 API才能實現/ NETONLY功能。 如果您LOGON_NETCREDENTIALS_ONLY
練習,那么您需要使用LOGON_NETCREDENTIALS_ONLY
:
http://www.pinvoke.net/default.aspx/advapi32/createprocesswithlogonw.html
更多資源:
以不同用戶身份運行作業:
Start-Job -ScriptBlock {whoami} -Credential (get-credential) | Wait-Job | Receive-Job
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.