Get-CimClass changes
One thing that I don’t think I’ve mentioned is that the Get-CimClass output changed during the development process. In PowerShell v3 RTM you can dig into a WMI class like this Get-CimClass -ClassName...
View ArticleCreating DNS PTR records
When I was writing the DNS chapter of PowerShell in Practice I couldn’t get the CreateInstanceFromPropertyData method on the MicrosoftDNS_PTRType class to work. Revisiting DNS for AD management in a...
View ArticleTime oddity
I was looking for a test of time synchronisation on domain controllers and knew that the .NET domain controller object held a system property. So, I cam up with this $dom =...
View ArticleUsing WMI methods with the CIM cmdlets
Using WMI class methods with the CIM cmdlets can cause a lot of confusion. This article, of mine, should clear up that confusion for you....
View ArticleCDXML
Its been stated many times that over 60% of the modules in PowerShell 3 & 4 are created using CDXML – objects-over-cmdlets. This involves taking a WMI class and wrapping it in XML to create a...
View ArticleCDXML: Module Manifest
Last time we created a module using CDXML to wrap the Win32_Bios WMI class. This gave us a cmdlet – Get-Bios. As the intention is to create a number of modules that expose the WMI classes related to...
View ArticleCDXML: Add a cmdlet for computer system
Continuing the creation of a Hardware investigation module – its a simple matter to add a cmdlet to retrieve the computer system data ie Win32_ComputerSystem First create a CDXML file like this:...
View ArticleCDXML–scripting creation
So far you’ve seen how to create CDXML files by hand – though you probably used cut and paste rather than typing everything from scratch. Its time to bring a bit of automation to creating CDXML files....
View ArticleTransferring modules from Windows 8 or 8.1 to Windows 7
Windows 7 shipped with PowerShell 2.0 installed. Windows 8 brought PowerShell 3.0 and Windows 8.1 brings PowerShell 4.0. Windows 8 and 8.1 also have a lot of modules installed. This extra...
View ArticleCDXML–network adapter configuration
I’ve amended the new-cdxml function created earlier in the series: function new-cdxml { [CmdletBinding()] param ( [Parameter(Mandatory=$true)] [string]$class, [Parameter(Mandatory=$true)]...
View ArticleCDXML–adding search parameters
Last time you saw how to create a cmdlet from the Win32_NetWorkAdapterConfiguration class: <?xml version=’1.0′ encoding=’utf-8′?> <PowerShellMetadata...
View ArticleCDXML–NetworkAdapterConfiguration–IP Enabled
Last time we added a search parameter enabling this: Get-NetworkAdapterConfiguration -DHCPEnabled $true I also want to be able to search based on if the adapter if IP Enabled using:...
View ArticleCDXML–NetworkAdapterConfiguration–Search on Index
The Win32_NetworkAdapterConfiguration class has an Index and an InterfaceIndex property. Both are suitable search properties. The take an unsigned integer as their value – leading to this addition to...
View ArticleCDXML: Cim jobs
One of the freebies you get when using CDXML is that the cmdlets you create automatically get the –AsJob parameter. I was thinking about jobs in general and realised that I didn’t know how CIM jobs...
View ArticleTest windows activation
I’m currently upgrading my lab environment to Windows Server 2012 R2 which involves upgrading some machines and rebuilding the others. One task in any build or upgrade situation is to make sure that...
View ArticleCim cmdlet aliases
I don’t use aliases in scripts/functions and don’t use them much at the command line. One alias I do use reasonably often is gwmi for Get-WmiObject – mainly because I do a lot with WMI. I’m using the...
View ArticleWin32_Process examples–processor time and memory usage
I saw some example code for using Win32_Process and didn’t like it so decided to create my own versions. In this case the objective is to display the processor time and memory usage: function...
View ArticleWin32_Process examples: get process owner
Moving on with examples of using Win32_Process you can find the process owner: function get-procowner { [CmdletBinding()] param ( [string]$computername = $env:COMPUTERNAME ) Get-CimInstance -ClassName...
View ArticleWin32_Process examples–set priority
Changing the priority of a process can give a processing boost to an application – but its not always a safe option. You can modify the process like this: function set-procpriority { [CmdletBinding()]...
View ArticleWin32_Process examples–terminate process
Terminating a running process is simply a case of calling the Terminate method: function remove-proc{ [CmdletBinding()] param ( [string]$computername = $env:COMPUTERNAME, [string]$processname )...
View Article