6
我遇到了從不同位置運行powershellscript的問題(c#應用程序,webservice ...)。 我認爲這是一個用戶上下文問題,所以現在我試圖找出在哪個用戶上下文powershell腳本運行。獲取當前用戶上下文
有沒有可能記錄powershellscript的當前usercontext?
我遇到了從不同位置運行powershellscript的問題(c#應用程序,webservice ...)。 我認爲這是一個用戶上下文問題,所以現在我試圖找出在哪個用戶上下文powershell腳本運行。獲取當前用戶上下文
有沒有可能記錄powershellscript的當前usercontext?
如果您需要了解實際的用戶:
[reflection.assembly]::LoadWithPartialName("System.DirectoryServices.AccountManagement")
[System.DirectoryServices.AccountManagement.UserPrincipal]::Current
用途:
[System.DirectoryServices.AccountManagement.UserPrincipal]::Current | gm
到了解UserPrincipal
的可用屬性/方法。
您可以使用WindowsIdentity class來獲得當前線程的用戶:
[Security.Principal.WindowsIdentity]::GetCurrent()