Archive for the ‘Windows PowerShell’ Category


 

Which PowerShell Versions are Users Running?

Monday, June 20th, 2016 by June Blender
In March 2016, SAPIEN Technologies, Inc. posted a survey asking users and administrators which versions of Windows PowerShell they're running. We got 148 responses by the April 8 when we closed the survey. This blog post reports the findings. While reading them, please keep in mind that this is not a statistically valid survey. We didn't select users or control for anything. Still, I did not expect these results. I might be a bit naïve about enterprise computing, but I'm surprised by the widespread adoption of Windows PowerShell 4.0 and 5.0. My sense is that the community moved much more…   More »

How to Pass Parameters to a Pester Test Script

Friday, June 17th, 2016 by June Blender
Applies to Pester 3.4.0 Like any Windows PowerShell script, a script that contains Pester tests can include parameters. It's easy enough to run the script and pass parameters and values in the usual way. But, when you use Invoke-Pester to run the script, you need to pass the parameters in a hash table. This blog explains how to do it. This post is the third in a series about how to run Pester tests. See also, How to Run Pester Tests and Invoke-Pester: Run Selected Tests. See the posts in this Pester series: How to Run a Pester Test Invoke-Pester:…   More »

Invoke-Pester: Running Selected Tests

Wednesday, June 15th, 2016 by June Blender
Applies to: Pester 3.4.0 In How to Run Pester Tests, I talked about the different places that you can put your Pester days and the different ways to run them, including, but not limited to, the Invoke-Pester function. Today, I'll talk about the parameters of Invoke-Pester function that let you determine which tests run. Next, I'll show you how to pass parameters to a Pester test file. By default, Invoke-Pester runs all *.Tests.ps1 files in the local directory and its subdirectories. That's a useful default, but the parameters of Invoke-Pester let you control the alternatives. See the posts in this…   More »

How to Run a Pester Test

Monday, June 13th, 2016 by June Blender
Applies to: Pester 3.4.0 When you crack open the Pester module, you find the New-Fixture function, which creates a script and test file pair, and the Invoke-Pester function, which runs Pester tests. But New-Fixture is not the only way to create a Pester test and Invoke-Pester is not the only way to run a test. In this blog post, we'll discuss the different ways to run a Pester test, including, but not limited to, the Invoke-Pester function. In the next post, I'll rave about the cool parameters of Invoke-Pester. See the posts in this Pester series: How to Run a…   More »

Use PSScriptAnalyzer in PowerShell Studio

Wednesday, May 11th, 2016 by June Blender
Applies to: Windows PowerShell 3.0 and later PSScriptAnalyzer 1.1.0 and later PowerShell Studio 5.2.118 and later PowerShell Studio has long supported best practices in Windows PowerShell, including running and debugging without profiles, avoiding cmdlet and parameter aliases (right-click\Expand to cmdlet, Expand all aliases: Ctrl+Shift+A), using consistent formatting to make maintenance and debugging easier, and using module-qualified command names (Ctrl+Shift+H). Beginning in PowerShell Studio 5.2.118, we've added deep support for PSScriptAnalyzer, the static analysis tool designed especially for Windows PowerShell. To use the Script Analyzer features in PowerShell Studio, you must be running in Windows PowerShell 3.0 and later and have…   More »

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 »

Giving a talk? PowerShell Studio Presentation Features

Wednesday, March 30th, 2016 by June Blender
One of the best parts of the PowerShell community culture is the willingness of people at all levels of expertise to help others to learn. It acknowledges that we learn from each other all the time and pays backward and forward for help that others have given to us. So, there are many people giving talks and presentations about PowerShell. And, PowerShell Studio has several features that make presentations easier. Filegroups: Open all scripts and modules for your presentation in a single click, even if the code files are on different machines in different locations. The files open in PowerShell…   More »

PowerShell Studio 2016: Service Release v5.2.118 and PSScriptAnalyzer

Monday, March 28th, 2016 by David Corrales
We released a new service build for PowerShell Studio 2016 (v4.2.118). Here's what's new:   Support for PSScriptAnalyzer module PSScriptAnalyzer module is a community driven module that evaluates your PowerShell scripts and ensures they follow community approved best practices. http://www.powershellgallery.com/packages/PSScriptAnalyzer/   PowerShell Studio 2016 now allows you to run PSScriptAnalyzer directly from the ribbon (Tools->Analysis->Analyze Script): Note: This option will be disabled if the PSScriptAnalyzer is not installed.   When you use the Analyze Script command, the module results are displayed in the Debug Panel: Jump to the respective line in the script by double-clicking on result.   Triggered Analysis…   More »

Exporting from Modules: A Reminder

Thursday, March 24th, 2016 by June Blender
There are so many new things in Windows PowerShell that I often assume that I know the basics. But, while working on a project about modules, I ran into some new guidance from PowerShell developer Jason Shirk and a great blog post that demonstrates that information about variables in a TechNet topic about module manifests is wrong. Here are some important reminders about modules and their manifests: By default, all functions and aliases are exported, but variables are not exported. "By default, all variables are exported" in How to Write a Module Manifest (MSDN) is wrong. This topic is outdated…   More »