Articles

PowerShell articles, tutorials, and guides from community experts.

Don Jones
PowerShell for Admins

Planning the PowerShell Summit North America 2014

We’re already planning for the 2014 Summit… you have to get way out in front of these things to secure space, plan a budget, and more. Here’s what we know: We’ll definitely still be in the Seattle metro area. That’s the best way to ensure participation from the PowerShell team, since it doesn’t require them to leave town for days at a time. We’ll be in April 2014. We’re going to try for April 14-16 to avoid Easter, or April 28-30.

Richard Siddaway

Select-string "“ keeping in context

Today"™s question involves using the Context parameter: *It’s probably just me, but I’ve never gotten the switch ‘-context 5 *or -context 2, 7′ to work predictably – where 5 lines before and after or 2 before and 7 after will come out – have you? Let"™s start by looking at the default behaviour of select-string using the search pattern you"™ve seen previously: PS> Select-String -Path c:\test*.txt -Pattern “\A\w{5}ABCD” C:\test\fixedcol.txt:1:12345ABCD123451234512345 C:\test\fixedcol.txt:3:12345ABCD123451234512345

Don Jones
PowerShell for Admins

Writing 10961A: The Damn Variables

When I wrote Microsoft course 10325A, their original 5-day Windows PowerShell course, I saved variables until Module 11. My thought at the time was to focus on teaching just what students needed for what they were about to do - and no more. “Just in time learning” can be effective, because it lets you immediately experiment with whatever you’ve just learned, and helps minimize the need to store up concepts for later use.

Richard Siddaway

Select-String "“ finding the first and last matches

Today’s question concerns finding the first and last matches in a file Sometimes, I need to make two passes at seeking content in this file, once for the first occurrence; and a second grep for obtaining the last occurrence of a phrase. After the second pass, I figure placing the values into an array is the best way, then need to combine first and last values onto one output line {somewhere else}.

Richard Siddaway

Workflow article 3

The next in the series of articles on PowerShell workflows that are appearing on the Scripting Guy blog has been published. The articles in the series that have been published are: http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx Look for the next article in one weeks time. Until then Enjoy!

Richard Siddaway

Select-String"“information on matching files

Following on from yesterday"™s post this is the second question: Since I’m recursively searching thru files to find matching phrases, how can I obtain other directory service information about the matching files file(s) – this is more of a methodology technique question because I realize there are multiple ways of achieving this? You could do something like this foreach ($find in Select-String -Path c:\test*.txt -Pattern “\A\w{5}ABCD” -List){ Get-ChildItem -Path $find.Path

Don Jones
PowerShell for Admins

3 Updated Free PowerShell eBooks in January 2013!

I’ve been working to update my three free PowerShell ebooks for this month: Secrets of PowerShell Remoting Creating HTML Reports in PowerShell Making Historical and Trend Reports in PowerShell The updated versions will be made available to subscribers of the PowerShell.org TechLetter on January 15th. If you’re not already signed up to receive this, you can [sign up right now][1]. The January issue will also feature a walkthrough article of how I started creating a new, better ConvertTo-HTML command, which gets used in the ebook on HTML reporting.

Richard Siddaway

Select-String scenarios "“ fixed columns

I had some questions come in after mu recent post regarding select-string. I"™ll answer them as a series of posts. First off: I’m recursively searching thru many files, and want to pull out specific data in ‘fixed column’ positions from the line(s) that match the phrase I’m seeking, i.e. position 10 thru 15 of the line or position 6 thru the end of the line (which might be unknown). What is your preferred method for handling this situation?

John Mello

PhillyPoSH 01/03/2013 meeting summary and presentation materials

User group member Greg Martin gave a presentation on Active Directory and PowerShell. A copy of his presentation can be found here and included the following topics: Building a copy of your production AD domain Notifying users of expiring passwords Dealing with expired computer accounts User group member Sunny Chakraborty gave a presentation on how to use the techniques of Prof George Poyla and Chess Grandmasters in order to improve your scripting skills.