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()