Tag: PowerShell

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 [...]

PowerShell Function to Determine the Active Directory FSMO Role Holders via the .NET Framework

Last week I posted a PowerShell function to determine what Active Directory domain controllers held the FSMO roles for one or more domains and forests. That particular function used the Get-ADDomain and Get-ADForest cmdlets which are part of the Active Directory PowerShell module. As it so happens, a friend of mine, Shay Levy who is a PowerShell MVP posted an article on PowerShell Magazine that uses a couple of one liners that use the .NET Framework to return the FSMO role holders. I'm not Read more [...]

Use PowerShell to Find Where the Current FSMO Roles are Assigned in Active Directory

A while back, I had a need to figure out with PowerShell what server in an Active Directory domain held the PDC Emulator FSMO Role. I found a script on a very popular blog site that figured it out by using a command similar to this: While it accomplished what was necessary, I immediately thought "I can do better" and improved the one liner so it filtered left: At the April Philadelphia PowerShell User Group meeting, Read more [...]

Using PowerShell v3 Features to Figure Out the Mysterious PowerShell Pipeline

I actually wrote this blog a couple of weeks ago and postponed it until I could do further testing because I thought of some scenarios where it possibly wouldn’t work. I wrote a couple of new blogs over the past couple of weeks and forgot about this one. Low and behold, I had rescheduled this blog for today and forgot all about it so I had two blogs posted today! I also have to say the PowerShell community is awesome! I had a PowerShell MVP send me a very courteous email that confirmed my previous Read more [...]