KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a script(Let's call it myPSScript.ps1) which takes two parameters and performs predefined steps. Script is located in a Windows Server box which people login and execute the script. Supports two users to be logged in at the given time. I want to find out who invoked the script. (Get-WmiObject -Class Win32_Process | Where-Object {$_.ProcessName -eq 'explorer.exe'}).GetOwner() | Format-Table Domain, User This works when the user is logged in currently and trying to run the script. But what if I have a batch file in scheduled tasks and run the same script? In that case the same command returns a null exception, as there is no one logged into the machine. Is there a way to find out who/which process invoked the powershell script. I vaguely remember Start-Transcript records which user the command is run from etc, so this should be possible? Thanks! Sanjeev
Tags (comma-separated)
Save Edits
Cancel