Tag: PowerShell

Want to Hear the Winner of the Advanced Category in the 2013 Scripting Games Speak?

Here's where you can hear me speak over the next few months: July 2013 Thursday, July 11th (Tonight), at 9:30pm Eastern Time (8:30pm Central Time) PowerScripting Podcast Guest (Winner of the 2013 Scripting Games Advanced Category) August 2013 Saturday, August 3rd SQL Saturday #234 in Baton Rouge PowerShell Fundamentals for Beginners (Speaker) Show up early as there were 60 attendees in the 48 seat room that I was assigned the last time I presented this session in person (at SQL Saturday #220 in Read more [...]

How to Create PowerShell Script Modules and Module Manifests

My entry for the Scripting Games advanced event 4 contained four separate functions: I want to create a module that contains these functions. There are several different types of modules, but what I'll be creating is a "Script Module". Modules sound like something really complicated, but script modules are actually simple. Currently, I have the functions saved as a ps1 file which I dot-source to load the functions into memory, but I want to share this tool with others so it makes more sense to Read more [...]

PowerShell Version 4 New Feature: A UserName Property Has Been Added To Get-Process Output Objects

Thanks to a tweet from Mark Schill, I discovered that Get-Process now has an "IncludeUserName" parameter in PowerShell version 4: This means no more having to use WMI to determine what processes are being run by which users: For those of us who work in a terminal services environment, this is a really big deal. I do find it odd that it was added via a switch parameter instead of just making it another property. It kind of reminds me of how the Active Directory cmdlets are implemented. Read more [...]

PowerShell Version 4 New Feature: Requires Statements Now Let Users Require Administrator Access Rights If Needed

In PowerShell version 4, there’s a new “-RunAsAdministrator” option for the #Requires statement that prevents a script from executing unless PowerShell is running as an administrator. The information about this new option from the PowerShell version 4 "about_Requires" help topic is shown in the following image. To learn more about the requires statement, run "help about_requires" from within PowerShell. Here’s the message that's displayed if this option is specified and the person Read more [...]

Using a Counter Variable in a PowerShell Workflow Foreach -Parallel Loop

As I'm sure most of my blog readers are aware, I competed in the advanced track of the Scripting Games this year and ended up doing quite well. Two first place finishes and three second places finishes with the official judges and four first place crowd score finishes. I also ended up being the overall winner of the advanced track. A few days ago someone on twitter asked me as the winner of the Scripting Games advanced track, what I would do with it? I plan to use it as a tool. I'll continue doing Read more [...]

Win a Six Month Subscription to Interface Technical Training’s Video Collection by Solving this PowerShell Puzzle!

During the 2013 Scripting Games, I won three subscriptions, each good for six months of video training at Interface Technical Training. I have a subscription already so I asked Don Jones about re-gifting my prizes since I don't need more than one subscription so here's your chance to win one. The first video training subscription that I won was given to Rohn Edwards who is the co-founder of the Mississippi PowerShell User Group. We exclude ourselves from the normal swag giveaways we have during Read more [...]

Exclusive PowerShell in a Month of Lunches Special Lunchbox Bundle Giveaway

The June meeting of the Mississippi PowerShell User Group is tomorrow night, June 11th at 8:30pm Central Time. This is a virtual (online) meeting so anyone from anywhere can join in! Our guest speaker for this month is well known author, speaker, and PowerShell MVP Jeffery Hicks. While at the PowerShell Summit back in April, Jeffery donated a limited edition PowerShell in a Month of Lunches bundle to include a special limited edition lunchbox, Learn Windows PowerShell 3 in a Month of Lunches Second Read more [...]

2013 PowerShell Scripting Games Advanced Event 6 – The Grand Finale

For me, the Scripting Games have been a great learning experience this year. I've used many PowerShell features that I hadn't used before such as splatting, ADSI, Workflows, and producing html webpages with PowerShell. I plan to write detailed followup blog articles on each of these topics over the next few months. Event 6 was definitely challenging since I hadn't used workflows before but I also knew that's what was really needed to accomplish the given task properly (In my opinion). While you Read more [...]

2013 PowerShell Scripting Games Advanced Event 4 – Auditors Love Greenbar Paper

The requirements for the 2013 Scripting Games Advanced Event 4 can be found here. For this event I created multiple functions and I'm going to quote chapter 6, section 1 of the "Learn PowerShell Toolmaking in a Month of Lunches" book written by Don Jones and Jeffery Hicks, published by Manning: A function should do one and only one of these things: Retrieve data from someplace Process data Output data to some place Put data into some visual format meant for human consumption I started Read more [...]

2013 PowerShell Scripting Games Advanced Event 3 – Bringing Bad Habits from the GUI to PowerShell

I’m seeing a trend with a lot of PowerShell scripters. Many of us have a GUI, non-scripting background and we moved to PowerShell because we didn't want to be button monkeys clicking through the same options in the GUI day in and day out. I've always heard, if you’re going to do something more than once, do it (script it) in PowerShell. The trend I’m seeing is many are bringing their bad habit of wanting to repeat themselves over and over, day in and day out, to PowerShell. They write Read more [...]

People Who are Blogging About the 2013 Scripting Games

I'm sure that most people can easily find any of the blogs of the official judges from the 2013 Scripting Games. I recommend reading those blogs whether you're competing in the scripting games or not since there's a wealth of great information contained in them. The best place to find those blogs if you don't know already is the Judges Notes section under the Scripting Games area on PowerShell.org so there's no reason to duplicate them here. There are also a number of people who are competing Read more [...]

2013 PowerShell Scripting Games Advanced Event 2 – Why NOT to use the Win32_ComputerSystem WMI Class

The majority of the entries I've seen for the Scripting Games event 2 are using the TotalPhysicalMemory property from the Win32_ComputerSystem WMI class to determine the total amount of physical memory in a server. The property name is "TotalPhysicalMemory" after all so that's what it should contain, right? Not so fast, keep reading to discover why. Your manager needs an inventory of all of your company's physical servers that are located in three different data centers which are in different Read more [...]

2013 PowerShell Scripting Games Advanced Event 2 – Attention to Detail is Everything

Here's my approach to the 2013 PowerShell Scripting Games Advanced Event 2: When I start one of the Scripting Games events, I read and re-read the scenario because if you don't understand the requirements, you can't write an effect script, function, command, tool, etc. It's not a bad idea to print out the event scenario and highlight the high-points. Here's the scenario for Advanced Event 2 -An Inventory Intervention, I'll place the items in bold that I would normally highlight on my printout: Dr. Read more [...]

Lessons Learned from the Scripting Games Advanced Event 1

This is a continuation from my previous blog titled "2013 PowerShell Scripting Games Advanced Event 1 – Parameters Don’t Always Work As Expected". This isn't the exact script, but sections of it. You'll notice at the bottom of the first image shown below, I retrieve the list of folder names from the files variable to keep from having to make another call to the file system. Going from one variable to another in memory is a cheap operation where as going to disk to retrieve something is more Read more [...]

2013 PowerShell Scripting Games Advanced Event 1 – Parameters Don’t Always Work As Expected

The scenario for this event states the following which has been paraphrased: Someone allowed log files to build up for around two years and they're starting to causing disk space issues on the server. You need to build a tool to archive the log files because this has happened more than once. Applications write log files to a sub-folder in "C:\Application\Log". Examples are C:\Application\Log\App1, C:\Application\Log\OtherApp, and C:\Application\Log\ThisAppAlso. The log files have random file Read more [...]