troubleshooting Question

Powershell Script to Get Logged In Status of a Remote Computer

Avatar of IT_Support Private
IT_Support Private asked on
8 Comments1 Solution167 ViewsLast Modified:
Hi All,
I have a working script that shows me the logged in user and time it was logged in for the local computer, though how can I edit this to prompt me for the remote machine name so that I can search other pc's in the domain.
As I need to use my admin account, I was planning o using get-credentials at the beginning of it, but not sure how I should setup the prompt for the Remote Hostname.
I'm not too sure why the script shows me all the details in the result, though it gives me the details required so not too fussed about it.

$explorerprocesses = @(Get-WmiObject -Query "Select * FROM Win32_Process WHERE Name='explorer.exe'" -ErrorAction SilentlyContinue)
If ($explorerprocesses.Count -eq 0)
    "No explorer process found / Nobody interactively logged on"
    ForEach ($i in $explorerprocesses)
        $Username = $i.GetOwner().User
        $Domain = $i.GetOwner().Domain
        Write-Host "$Domain\$Username logged on since: $($i.ConvertToDateTime($i.CreationDate))"
}[embed=file 1204108]
David Sankovsky
IT Manager

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros