I'd like to be able to detect in a script whether a Windows Server 2008 installation has specific Windows features enabled, and install them if necessary. I do not simply want to use a "try to install the feature, even if it is already installed" approach, as I need to be able to perform additional steps at the install time.
For example, I know I can install the SNMP Service using the command line:
pkgmgr /iu:SNMP
What I don't know is how to check whether this package has been installed, ideally from VBScript/WMI, but from a command-line tool if necessary.
Ideally I also want to find a solution that does not involve Powershell, as I don't want to have to lower the powershell execution privileges that are set by default in a Windows 2008 install.
Best Answer
It seems to me that you can do this easily with a powershell script (run as administrator).
Here is an example powershell script found on the internet:
You can find more information about finding out a feature's name in:
Windows Server 2008 R2: Adding Features via PowerShell
If WMIC is an option, see these articles:
New Server Core Tips
Using the new Windows Server 2008 Core OCList and OCSetup CLI tools to Add & Remove Server Roles
If programming is an option, see this stackoverflow article:
How can I programmatically check if a server feature is installed in Windows Server 2008?