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