PowerShell for Windows Admins:


September 25, 2013  2:10 AM

Server Documentation

Posted by: Richard Siddaway
PowerShell 3, WMI

No one likes documenting their servers but is a necessary job. As the start of a series on taking those first automation steps – you’ve learned PowerShell and now you want to put it to use – I have an article on the Scripting Guy blog that shows you how to get started documenting your...

September 20, 2013  2:39 AM

Using WMI methods with the CIM cmdlets

Posted by: Richard Siddaway
CIM, PowerShell 3, WMI

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. http://blogs.technet.com/b/heyscriptingguy/archive/2013/09/20/hey-dude-where-are-my-methods.aspx

September 9, 2013  2:04 AM

Getting WMI data from remote machines

Posted by: Richard Siddaway
PowerShell 3, WMI

WMI is great for pulling back data from remote machines. This type of activity is quite common: $computer = $env:COMPUTERNAME $comp = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer $os = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $computer $disk =...

September 8, 2013  7:28 AM

How much RAM does my machine have?

Posted by: Richard Siddaway
PowerShell 3, WMI

If you need to determine the RAM in a system you can use the Win32_ComputerSystem class Get-CimInstance -ClassName Win32_ComputerSystem | select Name, TotalPhysicalMemory The answer is in bytes BUT it only shows the memory available to the OS. Many systems steal RAM for graphics cards or...

September 1, 2013  4:57 AM

Find the key of a WMI class

Posted by: Richard Siddaway
PowerShell 3, WMI

At least one property of a WMI class will be marked as a key. This information is held in the property Qualifiers which is a collection of data. The key is needed if you need to create an instance of the class. I’ve shown how to find the key with Get-WmiObject before but not with the new CIM...

August 29, 2013  12:26 PM

DNS zone types

Posted by: Richard Siddaway
DNS, PowerShell 3, WMI

I was looking at the DNS zones for a project I’m working on. I needed to discover the conditional forwarder zone and hence the IP address of the DNS server to which the forwarding was occurring. The zone I wanted had a ZoneType of 4 which puzzled me. I remembered showing code to create a...

August 11, 2013  1:56 PM

WMI and Trusts

Posted by: Richard Siddaway
Active Directory, PowerShell, Windows Server 2012, WMI

When you install AD on a machine you get the MicrosoftActiveDirectory WMI namespace as well. This namespace was deprecated in Windows 2012 but while it is still available there are few useful things we can do with it. Even with my fondness of WMI I’m not suggesting moving to using WMI wholesale...

August 7, 2013  1:59 AM

Time oddity

Posted by: Richard Siddaway
Active Directory, CIM, PowerShell, WMI

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 = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() $dom.DomainControllers | Format-Table Name,...

July 7, 2013  1:01 PM

Deleting a file with WMI

Posted by: Richard Siddaway
File System, PowerShell 3, WMI

Following on from the last post this is how you can delete a file. Use the same file structure as previously This time you need to use the CIM_DataFile class. It’s one of the few classes I’ve found that doesn’t have a Win32_ equivalent. The class has a Delete method. Assuming you...

July 7, 2013  12:41 PM

Deleting Folders with WMI

Posted by: Richard Siddaway
File System, PowerShell 3, WMI

I recently saw a question about deleting folders with WMI. Let’s create a file structure we’re happy to delete New-Item -Path c:\ -Name Expendable -ItemType Directory New-Item -Path c:\Expendable -Name Target1 -ItemType Directory New-Item -Path c:\Expendable -Name Target2 -ItemType...

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: