Wednesday, August 30, 2017

VSCode as a replacement for the ISE

VSCode is a free source code editor developed by Microsoft and aimed at WIndows, Linux, and MACOS. VScode includes support for various languages, such as PowerShell, as well as embedded GIT control, syntax highlighting, code completion, and more.

Mike Robbins has produced a nice video, which you can find at http://mikefrobbins.com/2017/08/24/how-to-install-visual-studio-code-and-configure-it-as-a-replacement-for-the-powershell-ise/. This video takes you through the process of downloading VSCode, and setting it up as a replacement for the ISE.

It turns out to be remarkably simple to do this. Downloading is easy - and the installation process the normal clickercise approach. Once you get VS Code installed, you can easily configure it to act as the replacement for the ISE.

Once you have your settings configured, you end up with something that looks like this:



It looks and feels almost like the ISE, but with a lot of extra features above and beyond the basics provided by the ISE. These include the ability to determine aliases (and replace them with full cmdlet names), GIT hub/VSTeam Services/Hg integration and a lot more.

If you like the ISE, you are likely to enjoy VS Code!



Wednesday, August 16, 2017

Creating a SHA1 Hash - Using PowerShell

I recently saw a query about how to create a SHA1 hash, using Powershell. The post was looking at using a web site for this and accessing it via PowerShell's web processing. But there is a much simpler way - just using the .NET Framework. Here's a simple script that hashes a string:


# Create Input Data 
$enc      = [system.Text.Encoding]::UTF8
$string   = "This is a string to hash< $data     = $enc.GetBytes($string)
# Create a New SHA1 Crypto Provider
$sha1 = New-Object System.Security.Cryptography.SHA1CryptoServiceProvider
# Now hash and display results 
$ResultHash = $sha1.ComputeHash($data)
$ResultHash

The trick to this approach is to convert the string into a byte array and then pass the byte array to the ComputeHash method.