Forum Discussion

Brandon's avatar
8 years ago

PropertySource - Installed Windows Server Features

Useful for inventory, auditing, and auto-grouping.

Displays the a list of all installed Windows Features separated by commas.

Example below.

auto.winfeatures [Active Directory Lightweight Directory Services, .NET Framework 3.5.1 Features, Telnet Client, Remote Server Administration Tools, .NET Framework 3.5.1, Role Administration Tools, AD LDS Snap-Ins and Command-Line Tools, AD DS and AD LDS Tools, Active Directory module for Windows PowerShell]

 

WMN9DN

9 Replies

Replies have been turned off for this discussion
  • Brandon,

    I have modified the code slightly to get rid of the annoying open and close brackets(my OCD kicked in hard).

    groovy script:

    hostname=hostProps.get("system.hostname")
    my_query="Select NAME from Win32_serverfeature"
    def session = WMI.open(hostname);
    import com.santaba.agent.groovyapi.win32.WMI
    def result = session.queryAll("CIMv2", my_query, 15);
    def strResult = result.NAME.toString();
    def finalOutput = strResult.replace("["," ").replace("]"," ");
    println "WindowsFeatures=" + finalOutput

     

    P.S. - this script is awesome!

  • On 3/3/2017 at 6:12 PM, Brandon said:

    Useful for inventory, auditing, and auto-grouping.

    Displays the a list of all installed Windows Features separated by commas.

    Example below.

    auto.winfeatures [Active Directory Lightweight Directory Services, .NET Framework 3.5.1 Features, Telnet Client, Remote Server Administration Tools, .NET Framework 3.5.1, Role Administration Tools, AD LDS Snap-Ins and Command-Line Tools, AD DS and AD LDS Tools, Active Directory module for Windows PowerShell]

     

    WMN9DN

     

  • Good job @Brandon

    @mkerfoot OCD for brackets, but doesn't use a code block....

    I couldn't resist.

    hostname=hostProps.get("system.hostname")
    my_query="Select NAME from Win32_serverfeature"
    def session = WMI.open(hostname);
    import com.santaba.agent.groovyapi.win32.WMI
    def result = session.queryAll("CIMv2", my_query, 15);
    def strResult = result.NAME.toString();
    def finalOutput = strResult.replace("["," ").replace("]"," ");
    println "WindowsFeatures=" + finalOutput

     

  • Well, I had a few use cases come up for this, so I decided to take another crack at it.  I think this is going to work out better for us than my first version:

    hostname=hostProps.get("system.hostname") 
    my_query="Select Name, DisplayName, PathName from Win32_Service"
    def session = WMI.open(hostname);
    import com.santaba.agent.groovyapi.win32.WMI
    def result = session.queryAll("CIMv2", my_query, 15);
    def exclude = ['ALG', 'AppVClient', 'COMSysApp','diagnosticshub.standardcollector.service',
    	'FontCache3.0.0.0', 'EFS', 'KeyIso', 'msiserver', 'MSDTC', 'Netlogon', 'NetTcpPortSharing', 
    	'RpcLocator', 'RSoPProv', 'PerfHost', 'SamSs', 'SensorDataService', 'Spooler', 'sppsvc', 'TrustedInstaller', 
    	'UI0Detect', 'UevAgentService', 'VaultSvc', 'vds', 'VSS', 'WdNisSvc', 'WinDefend', 'wmiApSrv', 
    	'WRSVC', 'WSearch']
    
    result.each(){
    	if ((!(it.PATHNAME.toLowerCase() ==~ /c:\\windows\\system32\\svchost\.exe .*/)) &&
    	(!(it.NAME in exclude)))  {
    	    println "WinService." + it.NAME.replaceAll(' ', '') + "=" + it.DISPLAYNAME
    	}
    }
    
    return 0;

    Someone try this one and let me know if I missed anything obvious.  I tried to cut out all the noise so it would only spit out the services anyone really cares about.

  • Awesome job Guy's, loved it, but i wanted to show pretty much all the stuff so i updated it limiting the exclude to only Netlogon, 

    EMRLT9

    Screen Shot

    Love it.

    Medi