/build/static/layout/Breadcrumb_cap_w.png

Systems Management Question


Powershell command output and Custom inventory rule ouput is not same

01/20/2017 1064 views
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

Comments

  • 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.

All Answers

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.
Answered 01/21/2017 by: jgarcia29
Orange Senior Belt

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

    but result varies when executed on powershell and in Kace CIR
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. 
Answered 01/20/2017 by: chucksteel
Red Belt

  • when i open powershell using psexec..and enter whoami...it shows my user name..
    • 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")
    • This content is currently hidden from public view.
      Reason: Removed by member request For more information, visit our FAQ's.
    • 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/
      • PsExec.exe -i -s powershell.exe
      • 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")
      • You wouldn't use psexec in the CIR, it is used to test the output of the command when you run manually.

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