簡體   English   中英

以另一個用戶身份運行 powershell 命令

[英]Running powershell commands as another user

我正在嘗試從已刪除的對象 OU 中恢復測試用戶,並使用測試帳戶執行此操作。 問題是我無法讓測試帳戶運行命令而不會遇到“訪問被拒絕”錯誤。 測試用戶是一個組的一部分,可以像我一樣從已刪除的對象 OU 中恢復用戶,並且我能夠很好地運行相同的命令。 我想我做錯了$cred ,但不知道是什么。

$Cred = get-adobject -ldapfilter "(samaccountname=LOOKATME)" -includedeletedobjects -credential "testyboi" | restore-adobject 

我錯過了什么?

所以你需要使用創建憑證變量

$cred = Get-Credential

然后,您需要將該變量用作命令中的 -credential 參數。

get-adobject -ldapfilter "(samaccountname=LOOKATME)" -includedeletedobjects -credential 
$cred | restore-adobject

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM