Jump to content

Apps recently used by other accounts


iamtheky
 Share

Recommended Posts

My first playing outside of CIMv2, I dont know if you need to be a client of an SCCM for this namespace to be available.

#include<array.au3>

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output=""

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\ccm\SoftwareMeteringAgent")
$colItems = $objWMIService.ExecQuery("SELECT * FROM CCM_RecentlyUsedApps", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

Global $Aout[0]

If IsObj($colItems) then
   For $objItem In $colItems

       If stringsplit($objItem.LastUserName , "\")[2] = @UserName Then continueloop

      _ArrayAdd($Aout , "FolderPath: " & $objItem.FolderPath)
      _ArrayAdd($Aout , "ProductName: " & $objItem.ProductName)
      _ArrayAdd($Aout , "LastUsedTime: " & WMIDateStringToDate($objItem.LastUsedTime))
      _ArrayAdd($Aout , "LastUserName: " & $objItem.LastUserName)
      _ArrayAdd($Aout , "")

      Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "CCM_RecentlyUsedApps" )
Endif

_ArrayDisplay($Aout)

Func WMIDateStringToDate($dtmDate)

    Return (StringMid($dtmDate, 5, 2) & "/" & _
    StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Moderators

Out of curiosity, what version of SCCM do you have? I thought this would be a great addition (permission pending of course) to my SCCM UDF, but under 2012 R2 I do not see CCM_RecentlyUsedApps under namespace ccmSoftwareMeteringAgent. Are you by chance using 2007 still?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Im just a win7 client, I should have totally clarified that the unknown was whether it was available to all Win7 machines, or something that came from from the agent.  I would love to believe its a 2012 R2 server, I can confirm tomorrow.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

yeah, it doesnt work on my home laptop either.  I will investigate the version of SCCM and of the agent installed on my box and report back, thanks for the feedback...

and i was been exploring ways to do this with your UDF late today, but didnt know the site codes to even connect.  Is there a way to retrieve those, or do I have to ask the admin nicely what those are?

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Microsoft System Center 2012 R2.   I believe that Software Metering must be enabled on SCCM for clients to begin populating this namespace with data, but I could be misunderstanding...

http://blogs.msdn.com/b/minfangl/archive/2011/04/29/step-by-step-on-how-to-use-software-metering.aspx

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Moderators

To get the site info, go into Control Panel and launch Configuration Manager. You'll see the following on the General tab. The name of the server is what I have blocked out. Your site code is the P number (most of my customers leave it at P01).

post-54985-0-40288500-1426101764_thumb.p

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • 4 months later...

I am back to playing in SCCM with the new Win 8.1 powershell, and this task just became easier:

#include<Array.au3>
#RequireAdmin

$iPid = run("powershell Get-CimInstance -Namespace root\cimv2\sms -ClassName CCM_RecentlyUsedApps" , "" , @SW_HIDE , 0x2)

$sOutput = ""

 While 1
        $sOutput &= StdoutRead($iPID)
        If @error Then
            ExitLoop
        EndIf
    WEnd

$aOutput = stringsplit($sOutput , @CR , 2)
_ArrayDisplay($aOutput)

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Moderators

Yes, with R2 especially there are a lot more options in PS for both server-side tasks and endpoint management. I was thinking of rewriting the UDF, but it would basically just be a wrapper for the powershell commands at this point.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I was thinking of rewriting the UDF, but it would basically just be a wrapper for the powershell commands at this point.

But it would be a super nice wrapper.   I am just familiarizing and further exploring.  Like some classes i receive a "not implemented" (e.g. Win32_PingStatus) but am having trouble figuring out if that issue is between PS versions or OS versions, and moreover, why if it is 'not implemented' is it advertised by the provider?  Larger question would be, if I am enumerating __NameSpace is there a way to determine the items that are returned, but not implemented?

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...