Articles

PowerShell articles, tutorials, and guides from community experts.

Don Jones
Training

Calling all PowerShell Teachers/Trainers

I’m in the process of building a referral list for teachers and trainers who work with Windows PowerShell. My goal is to build a “find a trainer” page here on PowerShell.org, with the ability for prospective clients to send an inquiry via email. This would be for customers seeking private classes, not for individual students seeking a class.
If you’d like to be on the list, please send me an email, or use the “Contact” page under the “Site Info” menu here on PowerShell.org. Please provide an email address that referrals can be sent to; you’d receive the potential client’s contact information directly and would work with them directly - I’m not looking to act s middleman or agent, and there are no referral fees. We won’t be providing pricing information or anything other than a means of connecting clients and trainers.
You can also provide a link to your Web site, if you have one, preferably a page that describes your PowerShell training offering(s).

Don Jones

PowerShell Great Debate: Credentials

Credentials suck.
You obviously don’t want to hardcode domain credentials into a script - and PowerShell actually makes it a bit difficult to do so, for good reason. On the other hand, you sometimes need a script to do something using alternate credentials, and you don’t necessarily want the runner of the script to know those credentials.
So how do you deal with it?
Let’s be clear: This is not a wish list. Comments like, “I wish PowerShell could do ____” aren’t valid. What do you do using the technology as it exists today? Do you prompt for a credential and assume the script user will have it? Do you try to hardcode it? Do you set up a constrained endpoint? What?
[boilerplate greatdebate]

Don Jones
Announcements

TechSessions: Free PowerShell Webinars

PowerShell.org is going to be launching TechSessions this Fall. These will be ~1 hour online webinars, which you’re welcome to attend live. We’ll also record them and make the recordings available.
In most cases you will need to register for each one, so that we can send the appropriate invite information. Our sponsors are working with us on these, so each one might be in a different webinar platform (Lync, Webex, etc) depending on who is providing the infrastructure that month.
In all cases, we’ll announce the TechSession in our TechLetter Newsletter, via banners on this site, and in a blog post. You’ll notice a new “TechSessions” post category for those announcements.
I’ll be soliciting presenters, and the goal is just to provide you with varied technical content around PowerShell. If you’d like to BE a presenter, hit the Contact link in the Site Info menu (above) and let me know! Attending live will obviously give you a Q&A opportunity as well.
Be on the lookout! I’m hoping to kick off in September or October. If there are specific topics you’d like to see, drop a comment below and let me know. I’m sure potential presenters would love some suggestions, and I know I would.

Don Jones
PowerShell Summit

PowerShell Summit City Selection Criteria

As you may know, we’re in the process of putting together a PowerShell Summit Europe for Fall 2014. It’s a big task, with a lot of financial risks, so we try to get it right. Folks have been helpful on Twitter in offering city selection ideas… but there’s a bit more involved than just tossing out a city name. With that, here is the selection criteria!
Given the information below… AND the fact that Germany/UK/Netherlands (in that order) have been getting the overwhelming majority of “in what cities would you attend the Summit” votes… what cities would YOU recommend we consider?
(BTW, this is TOTALLY a chance to “sell” your suggestion - so do so! The criteria below are what’s really important to us, so help us understand how a given city helps meet all of that criteria! And, if you’re willing to help be our local ‘person on the scene’ to help organize, mention that also!)
-–
City Selection Criteria for PowerShell Summits
This guide is intended to provide a framework for selecting an appropriate city and venue for a PowerShell Summit.
Understand that a PowerShell Summit is meant to be a continent-level event, meaning the attendance of international speakers and attendees is a given. A PowerShell Summit is conducted primarily, if not entirely, in English, that being the “de facto” language of the technology industry, and the most-common language spoken by expert presenters in the field. A PowerShell Summit is open to everyone, and is not intended to fill the need for regional, culture- or language-specific events of any size. PowerShell.org recognizes the need for, and value of, those more-regional events, but the PowerShell Summit does not seek to full that need or provide that exact same value.
Throughout this guide, note that “venue” does not refer to a city. While in casual discussions we may refer to a city name or metropolitan area name - like London or Munich - our venue may not in fact be within the legal limits of such a city or area. “Venue” refers to a specific facility, which may be a hotel or a conference center or other specific location.
Our expectation is that most attendees will arrive at the event via common carrier - typically, train or airplane. Some may drive, but our focus is on providing good access for those who do not have their own personal transportation during the event.
Criterion 1: Airport Access
The first criterion is easy access to a major international airport. This is intended to accommodate the wide variety of attendees expected. In general, the venue should be either within a 15-20 minute drive from an airport by private car (including taxis and shuttle busses), or within a 30-minute ride via mass transit rail (specifically excluding public bus service, but including all levels of rail access).
Exception: The airport service area may be widened in instances where a venue offers significant other advantages in other criteria, or where the venue offers specialized access to expert presenters - e.g., using Bellevue for its convenient access to the PowerShell team, despite the fact that it is a ~30 minute ride by private car from SEA-TAC airport and lacks public rail access to the airport.
Criterion 2: Local Transit
The venue must be well-connected to the local area by mass transit rail (tram, train, metro, etc.). Alternately, the area must offer a variety of amenities within walking distance. Our goal is to minimize the need for rental cars to travel to the event venue from local hotels, restaurants, and other amenities. A 15-minute walking radius is a good “maximum” guideline. Due to this criterion, local parking fees are explicitly not considered during venue selection, although the organization recognizes than some local attendees may be impacted by parking fees.
Criterion 3: Evening Amenities
The selected venue must be accessible (via local rail transit or short walks) to evening amenities, including hotels, restaurants, and so forth. While the PowerShell Summit will often include evening events, attendees must have independent access to these kinds of amenities.
Criterion 4: Price, Quantity, and Quality of Lodging
The selected venue must be accessible (via local rail transit or short walks) to hotels of at least 3-star quality (as listed on travel Web sites such as Expedia or Orbitz), with as reasonable a price as possible given the choices of venues under consideration. When possible, the organization will reserve a room block for at least 1/3 of the expected attendance number (with the understanding that room blocks carry significant financial risk, and the organization has a primary goal of mitigating such risk). Additional hotel capacity meeting this criterion must be available, but may not necessarily be reserved, for the event.
Criterion 5: Language
The selected venue must be in an area where English is commonly spoken, at least by hospitality workers. English need not be the dominant language in the area, but as it is the “common language” of PowerShell, English must at least be commonly understood as a “lingua franca” in order for a maximum number of attendees to be able to navigate the area. Venues that do not meet this criterion may still be viable locations for a regional, cultural-specific event, but might not be qualified for a PowerShell Summit.
Criterion 6: Centrality
Given all of the other criteria previously listed, it is desirable to have a venue that provides equitable travel access from the majority of the target area. However, the organization recognizes that central location is often the most difficult to achieve in combination with the other criteria listed.
Criterion 7: Accessibility
The venue must conform with a general international standard of access for disabled persons, and must provide at least basic ability to meet common dietary restrictions, such as vegetarianism. The organization accepts that extremely specific dietary needs, such as cultural or religious needs or allergy concerns, might incur extra costs that would be passed along to the concerned attendee(s).
Criterion 8: Appropriateness
The venue must provide appropriate meeting facilities. This means the venue must be able to accommodate the expected number of attendees in a comfortable and safe surrounding, and attendees must be able to access the venue without undue overhead (e.g., extensive security checks in an office building, etc.). In multi-track events, meeting rooms should be able to accommodate a 15-20% offset (e.g., in a 300-person event with 300 attendees, each room must be able to handle 120 attendees, to deal with the fact that some sessions will be more popular than others).

Don Jones

PowerShell Great Debate: Piping in a Script

Take a look at this:

`# version 1 Get-Content computers.txt | ForEach-Object { $os = Get-WmiObject Win32_OperatingSystem -comp $_ $bios = Get-WmiObject Win32_BIOS -comp $_ $props = @{computername=$_; osversion=$os.version; biosserial=$bios.serialnumber} New-Object PSObject -Prop $props }

version 2

$computers = Get-Content computers.txt foreach ($computer in $computers) { $os = Get-WmiObject Win32_OperatingSystem -comp $computer $bios = Get-WmiObject Win32_BIOS -comp $computer $props = @{computername=$computer; osversion=$os.version; biosserial=$bios.serialnumber} New-Object PSObject -Prop $props } `These two snippets do the same thing. The first uses a more “pipeline” style approach, and I’ve personally never felt the urge to do that in a script. Probably habit - I come from the VBScript world, so a construct like foreach($x in $y) is natural for me. I’ve seen folks get into that “pipeline” approach inside a script and get into trouble, and if I’m scripting I often prefer to use the more formal, structured approach of the version 2 snippet.
What’re your thoughts? For me, version 1 has some downsides - forcing yourself into that pipeline structure can be limiting, and I find the approach in version 2 to be more readable and a bit easier to follow. Frankly, I’m never a fan of having to mentally track what’s in $.
(Which brings up a sidebar: I tend to evaluate a script’s goodness based on how well I can understand what it does without running it. That’s a common criteria, in fact, and one I personally think helps aid in debugging as well as maintaining scripts.)

_
Anyway… discuss!
[boilerplate greatdebate]

John Mello

PhillyPoSH 07/11/2013 meeting summary and presentation materials

  1. Active Directory SDK team member and former Senior Programing writer for the Windows PowerShell team, Jun Blender gave a presentation on The Hidden Charms of Windows PowerShell 3.0 via Lync. You can get a copy of her presentation here and see a recording of the Lync meeting on our YouTube channel
  2. Microsoft Technology Evangelist Yung Chou gave demonstration on how to use the PowerShell Azure cmdlets to automate data center deployments
    1. You can try doing the same and test server 2012 R2 out with a free 1-month trial of Windows Azure
  3. General Announcements
    1. The Microsoft Virtual Academy is hosting 2 separate day long PowerShell learning sessions that will be taught by the lead Architect of PowerShell Jeffery Snover and PowerShell.org board member Jason Helmick. Link to the sessions are as follows:
      1. Getting Started with PowerShell 3.0 : 7/18/2013 9AM-5PM PDT
      2. Advanced Tools & Scripting with PowerShell 3.0: 8/1/2013 9AM-5PM PDT
    2. The PowerScript Podcast is looking for show ideas
    3. In the wake of the 2013 scripting games there are many entries in the “Great Debates” series, in which the community discusses the differing techniques that the community used during the games
      1. Speaking of the scripting games, the winners were on the PowerScritping Podcast this week
      2. Mike Robbins, the winner of the advanced category, will be presenting for us in September!
        1. Mike also runs the virtual Mississippi PowerShell User Group and makes his meetings available to everyone.
    4. Last month"™s speaker, Rohn Edwards, has recently blogged about how to use some of the functions included in his PowerShellAccessControl Module
    5. Check out Chocolatey which is a Machine Package Manager, somewhat like apt-get, but built with Windows and PowerShell in mind.

Boe Prox
PowerShell for Admins

Working with the WSUS API and the SUSDB Database using PowerShell

Tthe WSUS API can be used to perform a multitude of WSUS tasks from approving patches, removing clients to creating automatic approval rules to many other things. By diving deeper into the API reveals that we can also find out the name of the SQL server (if using a remote SQL database server) that the SUSDB database is residing on. Beyond that, we can actually perform queries to the database (using TSQL) or perform tasks against the database itself.
I’ve written a couple of articles hat focus on making the database connection via the WSUS API and preform a simple query and then following up on that by performing some database maintenance by re-indexing and updating the statistics on the database tables.
Use the WSUS API and PowerShell to query the SUSDB Database
Using the WSUS API and PowerShell to Perform Maintenance on the SUSDB Database

Don Jones
Announcements

PowerShell Summit… EUROPE?!?!?

I have received a lot of interest in a PowerShell Summit Europe, and we are starting to look at doing one in 2014. I know that’s a long way off, but it takes time to put these together when everyone’s volunteering that time!
I have put together a very short survey to see if there is any consensus on where such an event might be held. The survey is online now and ready for your opinions. Please forward this to your colleagues and co-workers, as well - we would really like a variety of opinions. If you want to tweet about it, Facebook it, or anything else to help us get a broad perspective, it would be much appreciated.
I must note that this event will be in English, as it is meant to be a pan-European event that involves as many different folks as possible. We are not attempting to hold a more regional, culture-specific event - some of those already exist (I’m aware of one in Germany, for example), and they do a better job serving their local market (which can be quite large) than we could ever do. We are trying to fill a different need, which is more along the lines of a very miniature TechEd Europe, which brings as many different folks together as possible. Hopefully we will achieve that goal.
Thank you for your time and input!

Don Jones

PowerShell Great Debate: Backticks

Here’s an age-old debate that we can finally, perhaps, put an end to: The backtick character for line continuation.
The basic concept looks like this:

Get-WmiObject -Class Win32_BIOS -ComputerName whatever -Filter "something='else'"This trick relies on the fact that the backtick (grave accent) is PowerShell’s escape character. In this case, it’s escaping the carriage return, turning it from a logical end-of-line marker into a literal carriage return. It makes commands with a lot of parameters easier to read, since you can line up the parameters as I’ve done.
My personal beefs with this:

Don Jones
News

Would you contribute enterprise software reviews? [OFFTOPIC]

I’ve been working with a couple of folks lately who’ve been trying to review and pilot Active Directory auditing solutions. Both bemoaned the fact that, unlike consumer products of nearly any kind, IT products (specifically, enterprise software in this instance), don’t really get reviews from the admins who use those products.
So, I’m curious. If you could (a) anonymously, and (b) without giving your organization’s name, would you (c) leave reviews of enterprise software for other admins? You’d need to leave some obvious details, like the approximate size of your organization (number of users), what you expected the software to do, what it really did, what you liked, what you didn’t like, and so on.
Such a site would be a lot better (I think) than magazine or “professional” reviews, since you’d be reading the experiences of people who actually use the stuff every day. Yeah, as with any publicly-contributed content, review quality will vary - but you already know how to read between the lines, right? 😉
Drop a comment, or even send a tweet to @concentrateddon with “Reviews: YES!” or “Reviews: NO!” comment. Or if you prefer Facebook, leave that comment on my FB page. It sure seems like we IT professionals could use something like this - it’d be a good place to start researching solutions to particular problems, and a good place to share some real-world intel on how different solutions really work. Even if you don’t like writing reviews, would you use such a site as part of your research process?