WMI Namespaces - Is There An 'Official List'? - windows-xp

I'm (unfortunately) venturing into Windows (XP) scripting and WMI (Windows Management Instrumentation) as I am attempting to write scripts that will configure such things as network adapters, users etc.
Key to this seems to be the so-called WMI 'Namespaces'; once one has the name spaces apparently it's possible to discover classes within the namespace and read/alter data as necessary. (Apologies if I have misunderstood anything about WMI & namespaces).
So the obvious question is, just what WMI namespaces are available? It's fine being able to write a script that lists them but where is the official Microsoft list of namespaces? How on earth are you supposed to know what:
Namespaces official exist?
What classes are under each namespace?
Where do I look for a specific class say for network settings?

I created the list, you can see it at http://wutils.com/wmi/namespaces.html. It is not official list, of course. It contains list of namespaces in plain installation of Windows server with some extensions (sql server, exchange) and list of classes/properties/methods in each of the namespace.

1.Namespaces official exist?
AFAIK there is not a official list of WMI namespaces, but you can get the list of installed namespaces programmatically.
2.What classes are under each namespace?
Again there isn't a official list, but you can get this list connecting to each namespace and then executing this WQL sentence
select * from meta_class
3.Where do I look for a specific class say for network settings?
Take a look to the MSDN documentation Windows Management Infrastructure Classes
If you need more information about the WMI classes and namespaces I will recommend you use a tool like the WMI Delphi Code Creator, this tool allows you to generate code to access the WMI classes, events and methods. Also includes a set of options to search classes related to a specific keyword, execute WQL sentences, get metadata info about any WMI class and so on.

Related

Powershell Script to list all Domain connected hosts

I'm busy writing a script as a project to Audit Windows Servers for PCI compliance, One of the things my project lead has asked me to attempt to get to try to get a list of all hosts that are connected to a domain, however this script needs to be able to be run on any windows server without being able to import any modules, so I'm stuck with whatever tool already exists on a bare machine.
Ive already written parts of the script that can rely on the 'active directory' modules but I also need to find a way to get information without any DNS or Domain roles installed.
The closest I can get to achieving this is by using the 'netdom' command however this relies on usernames and passwords that I cannot query for in the auditing script.
Ive tried tools like nslookup and a few other things I've come across while looking for answers online, but most of it seems to rely on modules that I cannot install on the machines that the script will need to run on.
Does anyone know if this can actually be done? and if so how can I achieve this?
Edit: for a bit more clarity, I need a way to get a list of all machines in the domain from machines that are NOT a domain controller and I cannot alter these machines at all.
As per boxdog's comment "([adsisearcher]"objectcategory=computer").findall()" command works just fine

Get-stat equivalent via VMWare vSphere API

I'm developing an application that requires frequent access to the information that is provided through the PowerCLI Get-Stat command, and continuously interfacing with PowerShell has proven to be too slow.
We've been looking through the VMWare vSphere, but have had little success when it comes to finding a method that provides equivalent information. We have managed to access a VirtualMachine object, but it does not appear to provide any clear access to the Stats.
Is there a proper way to access the stats from the API? Or should I focus on optimising PowerShell interaction instead, parsing the resulting output?
If not using VMWare get-stat. You can use:
Direct VSphere access to DB performance stats.
try something like:
SELECT [SAMPLE_TIME]
,[SAMPLE_INTERVAL]
,[STAT_ID]
,[STAT_NAME]
,[STAT_GROUP]
,[STAT_ROLLUP_TYPE]
,[COUNTER_ID]
,[ENTITY]
,[DEVICE_NAME]
,[DEVICE_TYPE_NAME]
,[STAT_VALUE]
FROM [VSP02].[dbo].[VPXV_HIST_STAT_DAILY]
Take a look at this to use powershell to make SQL querys: https://sorrycantdothat.wordpress.com/category/sysadmin/
Connect to each VM's WMI and collect performance stats.

Get the machine name of an Azure worker or web role using PowerShell?

Is there any way using the PowerShell Azure cmdlets to get the machine name on which an Azure worker or web role is running? Specifically, I'm looking for the name that starts with "RD". I'm not 100% sure if I'm searching for this using the right terminology, because my results are clouded with information about Azure Virtual Machines. I've also been exploring the objects returned from such calls as Get-AzureDeployment and Get-AzureVM, but haven't found the "RD" name anyplace yet.
I've also found the discussion here, but wondering if it's out of date: http://social.msdn.microsoft.com/Forums/windowsazure/en-US/73eb430a-abc7-4c15-98e7-a65308d15ed9/how-to-get-the-computer-name-of-a-webworker-role-instance?forum=windowsazuremanagement
Motivation: My New Relic monitoring often complains "server not reporting" for instances that have been decommissioned. New Relic's server monitoring knows only the "RD..." names, and I'm looking for a quick way to get a list of these from Azure so that I can compare and see if New Relic is only complaining about old instances or if there's a real problem with one of the current instances.
You can actually get more significant host names than RD... by setting the vmName key in the cloud service's ServiceConfiguration file.
Then, your host names will be of the form vmnameXX, where XX is the instance number of the role. (i.e. "MyApp01", "MyApp02", ...)
For details on this, see the links below:
https://azure.microsoft.com/documentation/articles/virtual-networks-viewing-and-modifying-hostnames/
http://blogs.msdn.com/b/cie/archive/2014/03/30/custom-hostname-for-windows-azure-paas-virtual-machines.aspx

Powershell: Find out if NUMA is configured and how many CPUs are assigned to each NUMA node?

Using Powershell, how can I find out if my server has NUMA enabled and how many CPUs are assigned to each NUMA node?
Update:
I found out here that the microsoft.sqlserver.management.smo.server object object has an affinityinfo field. However, that field doesn't exist in my server object in Powershell when I create it (SQL Server 2005 on Windows XP).
Update:
It appears that the affinityinfo field only exists in SQL Server 2008 R2 and later.
There are APIs available that will get you this information but they are unmanaged which means they are not easily callable from PowerShell (.NET). In order to call these directly you have to use the Add-Type cmdlet to compile C# code into an in-memory assembly which you would then instantiate or invoke a static method from. I have an example of what this looks like on my blog.
Writing the C# is the tricky part because there is a lot of unfriendly looking code associated with it, check out this example. If you are familiar with C#, you might be able to adapt this to what you want. If not Mark has a tool called Coreinfo that looks like it will get you the information you are looking for. It actually calls the same unmangaged API that the linked p/invoke code does (GetLogicalProcessorInformation). You can just call this from PowerShell and process its STDOUT.
I don't think that native OS APIs in Windows 7 and Windows Server 2008 R2 for working with more than 64 logical processors are available in .NET, you can have a look to .NET Support for More Than 64 Processors. This guy use to write a .NET wrapper for OS APIs, you perhaps use that in PowerShell.

Connect to JMX using PowerShell

I am not a developer so please keep that in mind when reading the following message:
I need to be able to use Windows PowerShell to connect to a JMX RMI agent on a host, is this even possible ?
The example string from the java client I have been given is as below:
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:7979/jmxrmi");
The reason for this is that I am doing other work in my PowerShell script and would like to keep it all in one place.
Thanks !
This is an unusual mix of two technologies, but it is possible.
On the off-chance that you are attempting to connect to a JBoss server, the quickest way may be for you to call twiddle, a command tool that will dispatch JMX requests to the target JBoss server and return the results to standard out.
Another way is to implement the Jolokia agent on the target servers. This will allow you to issue JMX requests using REST. Responses will also be returned in REST format which you can process in PowerShell using one of these solutions.
Thirdly, you can also deploy the JMX-WS service on your target servers which will allow you to communicate with the JMX server using web-services. This document provides some VBScript examples of this.
None of the above actually uses the JMXServiceURL syntax you outlined, and I cannot think of a way you could actually cleanly integrate this RMI based protocol into PowerShell, but hopefully one of the above will work for you.
========== UPDATE ==========
There may be a way to use the RMI implementation. Take a look at IKVM. It is a Java Byte Code to .NET compiler. I have successfully compiled JMX/RMI java code into a .Net assembly and used it from C#. I think PowerShell will do the same thing.