Hi ,
I am trying to add to my already existing code below, where I want to see who is logged on using this code here: Just having some trouble, can anyone help?
gwmi -Class win32_process -Filter "name='explorer.exe'" | Foreach-Object { $_.GetOwner() } | select User.
__________________________________________________________________________________________
Existing script:
$Srvs = Get-Content 'serverlist.txt'
[string]$Body = Invoke-Command -ComputerName $Srvs -ScriptBlock { Get-Service Cpsvc | where-object { $_.status –eq "stopped"} } | select pscomputername | sort -Descending| ConvertTo-Html -Head $a
If ($Body -match "CTX"){
send-mailmessage -To "address" -from "address" -Subject "CTX print service stopped" -SMTPSERVER "IP" -Body $body -BodyAsHtml
}
Invoke-Command -ComputerName $Srvs -ScriptBlock { Get-Service Cpsvc | where-object { $_.status –eq "stopped"} | start-Service }