PowerShell

Automating the world one-liner at a time…

PowerShell Logo
Duplicate Files 2

A long time ago I posted a filter (AddNote) for adding notes to objects.  Some time later I posted a function (Get-MD5) for calculating the MD5 hash of a file and somebody asked how that could be used in a script to list all the files in a given folder that are very likely the same.

PowerShell Logo
Duplicate Files

Need a way to check if two files are the same?  Calculate a hash of the files.  Here is one way to do it:
 
## Calculates the hash of a file and returns it as a string.
function Get-MD5([System.IO.FileInfo] $file = $(throw ‘Usage: Get-MD5 [System.IO.FileInfo]’))
{
 

PowerShell Logo
Adding Notes

 

A while back I mentioned that there was a way of adding notes to objects in the shell. Here is one way to do it:

## Adds a note to the pipeline input.
filter AddNote([string] $name, $value)
{
$mshObj = [System.Management.Automation.MshObject] $_;

PowerShell Logo
MshObject and Methods that take object

Every once in a while people ( including me) run into trouble calling methods that take object.  Why?  Well, as I told you earlier objects in MSH are wrapped by an invisible MshObject.  As it turns out that this invisible object is not always so invisible.

PowerShell Logo
Support for Existing apps in Monad

Monad provides strong support for existing apps and technology.  If you use native cmdline exes, vbscripts, batch files, perl scripts etc to manage and maintain windows, you can pretty much use them the same way from monad as you would from cmd.exe.

PowerShell Logo
Did you know? #4

Did you know that you can access most of the Cmdlet base class APIs through script using the $executioncontext variable?
-Jeff Jones

PowerShell Logo
Did you know? #3

Did you know that you can put constraints on variables using the same attributes as cmdlet parameters?Unfortunately we had to postpone the language support for this but you can still do it using new-object.
MSH > $a = “foo”MSH > $varA = get-variable aMSH >

PowerShell Logo
Did you know? #1

Did you know that you can access the content of a provider using the variable syntax?
For instance, you can get and set the contents of a file just by doing the following:MSH > ${c:\temp\foo.txt} = “bar”MSH > ${c:\temp\foo.txt}barMSH >
Note,

PowerShell Logo
Did you know? #2

Did you know that you can make a variable automatically propagate to new scopes by using the AllScope option?
Normally when you enter a new scope variables are not copied from the parent scope. Instead we do a lookup for the variable when requested.

PowerShell Logo
Introduction to MshObject

If you’ve ever worked with the Monad APIs then you’ve no doubt seen a type called System.Management.Automation.MshObject.  I’m not going to go into all the details of what it is because that would take me more time than I have right now and there are people who can explain better than I. 

PowerShell

PowerShell Logo
PowerShell 7.1 Team Investments and Preview.1 Release

The PowerShell 7 release marks a huge milestone for PowerShell, the community, and the team!
Today we released the first preview for PowerShell 7.1! This release includes a number of changes that did not make it in time for the 7.0 release.

PowerShell Logo
Secret Management Preview 2 Release

Note this blog post is the third in a series on the releases of this module:

Secrets Management Development Release
Secrets Management Module Vault Extensions

We are excited to release a second preview of the Secret Management Module. Thanks to the tremendous feedback we received from the first preview release of this module,

PowerShell Logo
A new kind of GridView right in your console: Introducing the early preview of ConsoleGuiTools

Yes. This is yet another post about GridViews. We love them. You love them. What’s not to like?
If you’re not familiar with Out-GridView, it can be used to interactively view objects as a table allowing sorting and filtering. Many PowerShell users like to use it within a pipeline for interactive selection of objects that get processed later in the pipeline.

PowerShell Logo
Visual Studio Code for PowerShell 7

We are excited to announce that we have released a major update to the PowerShell extension for Visual Studio Code. This release contains months of architectural work that first shipped in our PowerShell Preview extension in November of 2019, along with incremental bug fixes in the intervening months.

PowerShell Logo
Announcing PowerShell 7.0

Today, we’re happy to announce the Generally Available (GA) release of PowerShell 7.0! Before anything else, we’d like to thank our many, many open-source contributors for making this release possible by submitting code, tests, documentation, and issue feedback. PowerShell 7 would not have been possible without your help.

PowerShell Logo
Secrets Management Module Vault Extensions

Secrets Management Module Vault Extensions
A new PowerShell Secrets Management module has been published on PowerShell Gallery. It is currently in a pre-release state and still in active development. Even though the module is not complete, we have released it to gather early community feedback.

PowerShell Logo
Public Preview of PowerShell Support in Jupyter Notebooks

Public Preview of PowerShell Support in Jupyter Notebooks
Today, the .NET team shipped an exciting new preview of .NET Interactive. If you’re unfamiliar, .NET Interactive (within a Jupyter environment) provides the ability to write .NET Jupyter Notebooks which are a powerful tool that combines documentation and the ability to execute and see the output of code all in the same file.

PowerShell Logo
Secrets Management Development Release

Secrets Management Development Release
At Ignite 2019 we gave a preview of our PowerShell Secrets Management Module. This Secrets Management module, first proposed in RFC #234, creates an extensible abstraction layer in PowerShell for interacting with Secrets and Secrets Vaults. We are excited to publish a development release of this module to the PowerShell Gallery to get feedback on the cmdlet interface and to enable an iterative development experience.

PowerShell Logo
Announcing the PowerShell 7.0 Release Candidate

After 6 previews, we’re happy to announce the release of the PowerShell 7 Release Candidate (RC). Whether you’ve been running PowerShell Core since our first alpha releases or you’ve been clinging to Windows PowerShell for backwards compatibility, 7.0 delivers a host of improvements to make your life better.

PowerShell Logo
Improvements in Windows PowerShell Container Images

Beginning with Windows Server 20H1 Insider builds, Windows Server Core Insider images have been reduced in size from ~2.1 GBs to ~1.1 GBs.
How did the Server Core images get over 40% smaller?
Traditionally, Windows 10 and Windows Server have always included a set of .NET native binaries that were pre-compiled using the Native Image Generator tool (Ngen.exe).