This post is based on the September 2014 preview release of WMF 5.0. This is pre-release software, so this information may change.
One of the banner new features in PowerShell v5 is support for real live .NET Framework class creation in Windows PowerShell. The WMF 5.0 download’s release notes has some good examples of what classes look like, but I wanted to briefly set some expectations for the feature, based on my own early experiences.
Hello everyone,
The Denver PowerShell User Group will be meeting again on September 4th and we will have Keith Hill presenting. Keith has published an ebook, is a repeat Microsoft MVP, and has been heavily involved in writing and maintaining the PowerShell Community Extensions.
You can find more information on the event as well as RSVP here:
Keith Hill - Effective PowerShell Thursday, Sep 4, 2014, 7:00 PM 899 Logan st
# List all classes in a namespace Get-CimClass -Namespace root\CIMv2 Get-WmiObject -Namespace root\CIMv2 -List # list all classes containing “service” in their name
Get-CimClass -Namespace root\CIMv2 | Where CimClassName -like ‘*service*’ | Sort CimClassName
(or)
Get-CimClass -Namespace root\CIMv2 -Classname *service*
Get-WmiObject -Namespace root\CIMv2 -List | Where Name -like ‘*service*’ | Sort Name
# get all class instances
Get-CimInstance -Namespace root\CIMv2 -ClassName Win32_OperatingSystem
Get-WmiObject -Namespace root\CIMv2 -Class Win32_OperatingSystem
# filter class instances
Trend Micro released a report on a new PowerShell-vectored exploit named Black Magic. I had a lovely Twitter conversation about what this means in terms of PowerShell’s vulnerability to attack, and what admins should do. Unfortunately Twitter sucks for carrying on that kind of conversation, so I wanted to post this to clarify a few things.
First, I’m going to write this article as if “you” were hit by this exploit.
I’m getting a lot of questions from folks, via Twitter and other venues, regarding Windows Management Framework 5.0 - which is where PowerShell v5 comes from. It’s awesome that people are installing v5 and kicking the tires - however, please help spread the word:
v5 is a preview. It isn’t done, and it isn’t guaranteed bug-free. It shouldn’t be installed on production computers until it’s officially released. v5 doesn’t install ‘side by side’ with v3 or v4.
There’s some great PowerShell content now online for your viewing pleasure.
Jeffrey Snover and I had a blast doing “Windows PowerShell Unplugged,” and I reviewed some best PowerShell practices (and hopefully provided a little inspiration for your career) in “Windows PowerShell Best Patterns and Practices: Time to Get Serious.” And the #2 overall session of TechEd? “DSC: A Practical Overview,” including a surprise demo (and announcement) from Snover showing DSC running on Linux.
After all the DSC-related excitement this week, there have been a few online and Twitter-based discussions including Chef, Puppet, and similar solutions. Many of these discussions start off with a tone I suppose I should be used to: fanboy dissing. “Puppet already does this and is cross-platform! Why should I bother with DSC?” Those people, sadly, miss the point about as entirely as it’s possible to do.
Point 1: Coolness First, what Microsoft has accomplished with DSC is cool.
I’ll be using these examples in my TechEd 2014 session on PowerShell patterns and practices. They won’t make much sense, perhaps, until you see the session (live, or in the recordings - and I believe this session is one of the “Taste of TechEd” ones that will be live-streamed), but here are the scripts.
TechEd-NA-2014-Patterns-Examples
What sorts of things would you want to configure via DSC that don’t already have a resource?
NB: Focusing on the core Windows OS and its components only; Exchange, SharePoint, SQL Server, and other products are off the table for this discussion.
For example, I want a “log file rotator” resource, that lets me specify a log file folder, an archive folder, and a pair of dates. Files older than one date are moved from the log folder to the archive folder; archived files older than the second date are deleted.