Archive for the ‘Howto’ Category


 

How to Write About Help for your Module

Monday, May 2nd, 2016 by June Blender
Since installing PowerShell 5.0, I've been using the PowerShellGet cmdlets to install and examine many of the new modules on PowerShell Gallery. Unfortunately, this is often quite a chore. While many have some help for cmdlets, few have an About topic that tells me how to use the cmdlets together to solve real-world problems. And, in those that do, the About topic feels like the authors wrote whatever popped into their minds at the time. In this post, I'll share my ideas for best practices for writing the primary About_Help topic for your module. Best Practices for a Module About_Help…   More »

Setting Conditional Breakpoints

Wednesday, April 20th, 2016 by June Blender
Applies to PowerShell Studio 2016, PrimalScript 2016, and later. I write lots of scripts — for production, for research, for testing, and for demonstrations. And, inevitably, I hit a bug. I'm actually relieved when I do, because no code is perfect and I'd rather find the bugs before my users do. In fact, I make sure the content in my test database is full of oddities so it's as close to the real world as possible. When you are debugging with a large test sample, like a database or directory, the default line breakpoints are not sufficient. I can hit…   More »

Open a SAPIEN Forum from PowerShell

Monday, March 21st, 2016 by June Blender
UPDATE:  Added a -Search parameter that searches all SAPIEN forums for the term that you specify and then opens the page with the results. Thanks to Prasoon V. Karunan for the contribution. I love helping people learn Windows PowerShell and SAPIEN products. I answer questions on Facebook, Twitter, Reddit (love the /r/powershell subreddit), Google+, Slack, email, in the line at Starbucks, etc. But, I'm also a scripter, and I know the value of automation and efficiency. So, rather than answer one question for one person, I'd rather answer each question for many people. And, to get the best answer, I'd like…   More »

My First Form: New Videos for PowerShell GUI Beginners

Monday, March 14th, 2016 by June Blender
Like most things, once you know the basics, it's really easy to build GUI applications with Windows PowerShell and PowerShell Studio. And, like most things, it's hard to learn the basics. We're here to help. We just posted a two-part series of videos. You can watch them in any order. My First Form: Build a Simple PowerShell GUI App is a step-by-step guide to building a little PowerShell GUI app that displays the versions of Windows and Windows PowerShell on your system. My First Form: Controls and Properties is like a prequel. It introduces you to the concepts of the Windows Forms controls…   More »

Update-Module 5.0 adds, not updates

Wednesday, February 17th, 2016 by June Blender
Applies to: -- Windows PowerShell 5.0.10586.63 -- PowerShellGet 1.0.0.1 I'm a huge fan of sharing Windows PowerShell modules and making them easy to find (Find-Module), view (Save-Module), and install (Install-Module). So, I truly love the new PowerShellGet module. However, you really need to understand how it works before you use it. Otherwise, you might end up with commands and modules that don't work correctly (or at all) or don't do what you expect. Or, you might download modules with commands that shadow or hide commands that your scripts run. Update-Module is one of the really useful cmdlets in PowerShellGet, but if you don't know…   More »

Using Prefixes to Prevent Command Name Collision

Monday, February 15th, 2016 by June Blender
In January, I had the honor of presenting to the Mississippi PowerShell User Group (MSPSUG). I've known the organizers, Mike Robbins and Rohn Edwards for years, and truly respect them. The PSUG is online-only, which makes it a challenge for presenters, but they attract a very sophisticated audience, so my talks there are really conversations. This was a perfect venue for my "Avoiding Version Chaos" talk. (More at PowerShell Saturday in Tampa on March 19, 2016.) In one part of the talk, I demonstrated how to use noun prefixes to distinguish among commands with the same names. The demo flopped…   More »

Using Group-Object to Detect Command Name Conflicts

Wednesday, February 10th, 2016 by June Blender
The Group-Object cmdlet, one of the original provider cmdlets, is as old as Windows PowerShell. It was introduced in version 1.0 and hasn't changed at all since then. But, it is one of my favorites. (You can tell when I love a cmdlet by the number of examples. Group-Object has 9!) In fact, when you use it frequently, you begin to see groups as a path to many solutions. Group-Object groups objects by the values of a property that you choose. So, it's a quick way to find the property values that appear in a data set. Which domain controllers are used by users…   More »

PowerShell GUI Apps: Why think in events?

Monday, January 4th, 2016 by June Blender
Always committed to starting the New Year right, I’m heading to Scottsdale, Arizona on Tuesday, January 5 at 5:30 PM to meet with the newly revived Arizona PowerShell User Group. We’ll meet at the Microsoft Store in Scottsdale Fashion Square. (I will not be distracted by the Surface Pro 4 on display. I will not…)   I’ll be there to lead an interactive hands-on lab in which participants build a basic PowerShell GUI application – essentially, a graphic user interface for a PowerShell script. When you press a button, it runs part of the script. When you type text in…   More »

How I learned to love DialogResult

Wednesday, December 23rd, 2015 by June Blender
This post discusses the DialogResult property of buttons, which often confuses beginning PowerShell GUI app designers. When I first started learning how to write PowerShell GUI applications, I thought of the DialogResult property of buttons as the "evil property." What else would I think? If the DialogResult property of a button is set to any value other than None, when you click the button, the GUI app closes immediately after running the commands in my event handler. In this little app, when you click OK, it pipes a Get-Service command to Out-GridView -- um, very briefly. [video width="1280" height="670" mp4="https://www.sapien.com/blog/wp-content/uploads/2015/12/DialogResult.mp4"][/video]…   More »

Where are v3 and v4? PowerShell Versions in PowerShell Studio

Monday, December 21st, 2015 by June Blender
In this post, we explain why PowerShell Studio can run your scripts only the versions of Windows PowerShell that are installed on local and remote computers. If you've recently upgraded to Windows 10 from Windows 7, 8, or 8.1, you'll notice quickly that you now have Windows PowerShell 5.0. Depending on your upgrade path and subsequent updates, you might be running any version of Windows PowerShell greater than or equal to 5.0.10240. Or, you might have installed the shiny new Windows Management Framework 5.0 for Windows 7 SP1, Windows Server 2008 R2, and later versions of Windows client and server. In…   More »