Articles

PowerShell articles, tutorials, and guides from community experts.

Colyn Via
PowerShell for Admins

The Ternary Cometh

Developers are likely to be familiar with ternary conditional operators as they’re legal in many languages (Ruby, Python, C++, etc).  They’re also often used in coding interviews to test an applicant as they can be a familiar source of code errors.  While some developers couldn’t care less about ternary operators, there’s been a cult following waiting for them to show up in Powershell.  That day is almost upon us.
Any Powershell developer can easily be forgiven for scratching their heads and wondering what a ternary is.  In the most basic sense a ternary evaluates an expression to a binary result and carries out one of two possible outcomes.  Lets start by looking at some code examples:

Missy Januszko
Announcements

Be a Speaker at PowerShell and DevOps Global Summit 2020!

We are so excited for the 2020 PowerShell and DevOps Global Summit! We’re about halfway through the CFP season and are still looking for your awesome submissions. If you are hesitating, please don’t… think seriously about submitting a topic or two. To help you, we’d like to give you some ideas about what makes a submission stand out (and what doesn’t).

  • Something Unique… We’re looking for a new spin or twist on an old (or new) topic. If something similar has been done at a previous Summit, think about how you’re doing something different from what’s previously been presented. DevOps topics are always popular, but what new thing are you doing with your source control, your testing, or your build pipeline?
  • Failures… Alternatively, is there something you started out to do and at some point, figured out that you it wasn’t going to work the way it was planned? If you’ve had some good lessons learned that you think would benefit others, we’d love to hear about it.
  • Broad scope vs. deep scope… If you’ve done a snack “bake-off” and could talk about chips, cookies, and crackers, this session would be attended by folks who prefer chips or cookies or crackers. However, a session that is only about cookies might only be of interest to Rambling Cookie Monsters. If you’re a subject matter expert on chips, though, and can show how to use chips to build a house, that would have that uniqueness factor we’re also looking for.
  • Multiple submissions… Multiple submissions on different topics help us select a wide variety of topics. It’s hard to say from year to year what topics will be popular. For example, we had a lot of Git and Pester submissions last year… not so many this year. We’re looking for variety so submit as many ideas as you have.
  • Something that wasn’t selected last year… We may have really liked your submission last year and it may have simply been on the bubble. You’re only up against the submissions that we’ve seen for this year, so if you had a submission from last year that you feel passionate about and is still a hot topic, please submit it!
  • “Post OnRamp” submissions are welcome… We have a graduated class of OnRamp students from last year who we want to continue learning. Therefore, we’ll be looking for a small number of sessions at this level.

Some additional things we’d like to add:

tobor79
PowerShell for Admins

A Better Way To Search Events

I have put together a security script to use as an alerting system. Using a CSV file containing information on which users are assigned which computer, the event logs are searched to discover when a user signs into a device outside their normal assignments. The final result of that script can be viewed HERE if interested. I will do my best to provide unique real world search queries for my examples.

Colyn Via
PowerShell for Admins

A Peculiar Parse

 

One of the best enhancements to Powershell was the inclusion of custom classes in v5. We originally wrote scripts, then we wrote cmdlets, followed by modules, and now we’ve graduated, with Class.

I recently decided I wanted to write some code that would build a website. What better way to do that than by creating a class just for me? That’s rhetorical by the way. My early class code looked like this:

Robin Dadswell
PowerShell for Admins

ICYMI: PowerShell Week of 16-August-2019

Topics include Azure setups, AD reporting, IF statements Out-GridView and other new features coming in PowerShell 7.

Special thanks to James Petty, Mark Rollof, Prasoon Karunan V and Robin Dadswell

Pragmatic PowerShell Scripting - Reporting on AD Groups

by Chris Sharp on 11th August

Learn how Chris approached a requirement to pull various reports from AD using PowerShell and a useful Excel module.

Powershell: Everything you wanted to know about the IF statement