Posts Tagged ‘powershell 5.0’


 

Which Version Does Import-Module Import?

Wednesday, July 13th, 2016 by June Blender
Applies to: Windows PowerShell 5.0.10586, 5.1.14385.0, PowerShellGet 1.0.0.1 The Import-Module cmdlet, the #Requires directive, and module auto-loading (PS 3.0+) all import modules into a PowerShell session. But, which modules do they import by default? It's an important question when you are writing shared code that uses commands from other modules. And, the answer has become more complex with the advent of side-by-side versioning in PowerShell 5.0. Read the full post in the SAPIEN Information Center.   June Blender is a technology evangelist at SAPIEN Technologies, Inc. and a Windows PowerShell MVP. You can reach her at juneb@sapien.com or follow her…   More »

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 1.0.0.0…   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 »

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 »

Inheritance in PowerShell Classes

Wednesday, March 16th, 2016 by June Blender
If you're learning about classes in Windows PowerShell 5.0, one of the first new concepts that you'll encounter is inheritance. When you create a class that is based on another class, your new subclass or child class automatically gets the inheritable members (e.g. properties and methods) of the parent class or base class. Inheritance is a really powerful and useful concept, so it's important that you understand it. Fortunately, it's pretty easy. Also, the inheritance principles that you learn in PowerShell are also used in other programming languages, so learning them in PowerShell gives you a head start on new…   More »

Which versions of PowerShell do you run?

Tuesday, March 8th, 2016 by June Blender
The PowerShell team released Windows PowerShell 5.0 on Windows 10 last year and just re-released Windows Management Framework (WMF) 5.0 for earlier versions of Windows. But, we know from years of experience that many people don't upgrade their versions quickly. It takes time to get to know and trust a new version. In a large enterprise, it takes time to do the parallel testing to certify that a new product is secure and compatible with the software that the organization uses. Take the survey: Which version of Windows PowerShell do you use? For those of us who are writing scripts and modules to share, this…   More »

Finding PowerShell 5.0

Friday, February 26th, 2016 by June Blender
Updates: We have updated this blog post to reflect these changes. Windows Management Framework 5.0 RTM, which includes Windows PowerShell 5.0 for systems earlier than Windows 10, is now released. Windows Management Framework 5.0 is now available in the Microsoft Update Catalog. There are some amazing new features of Windows PowerShell 5.0. Some of them, including PowerShellGet, are available in Windows PowerShell 3.0 and 4.0. But, many very useful features, including the new advanced features of DSC, PowerShell classes, the information stream, remote debugging, copying between sessions, and advanced logging are supported only in 5.0. Unlike previous releases, Windows PowerShell…   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 »