/build/static/layout/Breadcrumb_cap_w.png

Powershell command output and Custom inventory rule ouput is not same

86kXRA.bmp
click here to view the image

i used powershell script to get the user login counts ..in powershell its shows right info
but in Kace inventory i see incorrect entries as shown in image.

in powershell window i can see only one user logged into that machine with count 356
but in Kace inventory i  see different results with some other username and count reaching upto 18938,though user has not logged into tht machine at all
how can i fix this issue



1 Comment   [ + ] Show comment
  • I did some more research and it looks like your PowerShell command is pulling the last login and number of logins from the domain and not from the local machine. I discovered this when I ran the command on my system and it showed that the last login for a colleague was this morning at 7:00am, which wasn't possible because my computer was off at the time. From what I have been able to find online the only way to get the number of local logins is to search the Security event log on the machine. - chucksteel 7 years ago

Answers (2)

Posted by: jgarcia29 7 years ago
Orange Senior Belt
0
What are you trying to output the last loggoned on user?
I wish kace cloud provide powershell support (better) and also powershell modules or provider for kace.

Comments:
  • i want to get the number of times user logged onto the machine.

    but result varies when executed on powershell and in Kace CIR - rahimpal 7 years ago
Posted by: chucksteel 7 years ago
Red Belt
0
It probably has something to do with the context when the script is run. You are running PowerShell in your user context and the CIR runs in the System context. To test this you can use PSExec to open a PowerShell as System and then try the command. 

Comments:
  • when i open powershell using psexec..and enter whoami...it shows my user name.. - rahimpal 7 years ago
    • how can i add psexec into this command

      ShellCommandTextReturn(cmd /c powershell.exe "Get-WmiObject -class Win32_NetworkLoginProfile | Where {($_.NumberOfLogons -gt 0) -and ($_.NumberOfLogons -lt 65535)} | Select-Object Name,@{label='LastLogon';expression={$_.ConvertToDateTime($_.LastLogon)}},NumberOfLogons") - rahimpal 7 years ago
    • Did you use the -s flag?
      https://blogs.technet.microsoft.com/askds/2008/10/22/getting-a-cmd-prompt-as-system-in-windows-vista-and-windows-server-2008/ - chucksteel 7 years ago
      • PsExec.exe -i -s powershell.exe - rahimpal 7 years ago
      • thanks chuck for your help

        but how can i add Psexec

        in this below command

        ShellCommandTextReturn(cmd /c powershell.exe "Get-WmiObject -class Win32_NetworkLoginProfile | Where {($_.NumberOfLogons -gt 0) -and ($_.NumberOfLogons -lt 65535)} | Select-Object Name,@{label='LastLogon';expression={$_.ConvertToDateTime($_.LastLogon)}},NumberOfLogons") - rahimpal 7 years ago
      • You wouldn't use psexec in the CIR, it is used to test the output of the command when you run manually. - chucksteel 7 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ