Posts Tagged ‘powershell’


Using a ModuleSpecification Object

Monday, June 27th, 2016 by June Blender
With the advent of side-by-side module versions in Windows PowerShell 5.0, the lovely, but obscure ModuleSpecification object has become your new best friend. Use it to make sure that the commands and module that you use are the ones that you intend. Using ModuleSpecification Let's start with an example. I want to get the Expand-Archive command in the Microsoft.PowerShell.Archive cmdlet. I can use Get-Command, of course, but when I surround the command name with wildcard characters to make sure it searches, it returns this: PS C:\ > Get-Command *Expand-Archive* CommandType Name Version Source ----------- ---- ------- ------ Function Expand-Archive…   More »

Testing Pester Code Coverage

Friday, June 24th, 2016 by June Blender
Applies to: PowerShell 5.0.10586.122, 5.1.14367, Pester 3.4.0 I'm one of those people who thinks a score of 99% is failing, so I love to see those 100% scores when I use the CodeCoverage parameter of Invoke-Pester. But, while assembling my Pester presentations for DevOps Global Summit 2016 and PowerShell Conference Europe 2016, I realized the 100% code coverage score means that 100% of my code (every line) ran during the test. It doesn't mean that 100% of my code is tested. Code coverage reports are really valuable, but you need to understand what they test and how to use them.…   More »

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 »

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.   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 »

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 »