If you have ever tried using Invoke-WebRequest to get a webpage using SSL, you will most likely have seen the following error message:
Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel.
The simple “fix” for this problem is to tell PowerShell to use TLS 1.2 instead of the default 1.0:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri "https://some.site.com"
The built-in commands to convert to and from JSON is some (of many) great reasons why PowerShell is such a joy to use. In this short blog post I’m going to write about using line breaks in strings together with ConvertTo-Json. (more…)
Just a quick tip on how to get and set environment variables using PowerShell, compared to how it is done in DOS. (more…)
If you need to open Windows Explorer from your current location while working in PowerShell, simply use this command: (more…)
Most users are probably happy with the default PowerShell prompt. But there are a handful of people that are not satisfied with any product unless they have had a chance to customize it to their needs. Luckily PowerShell supports defining your own prompt quite easily. Then there are another few that for some reason likes to have multiple prompts that they alternate between. Perhaps they have one for home, one for work and another one when they are presenting at usergroups and conferences. (more…)
The character set allowed in the Domain Names System is based on ASCII, but ICANN have later approved the Internationalized domain name (IDNA) system. It was proposed in 1996 and first implemented in 1998, and lets you use characters outside the ASCII-only scheme (Unicode). (more…)
When using the Format parameter of the Get-Date cmdlet, if you ever need a list of all supported format patterns, use this one-liner:
Recently, when reading string data from a binary file, I stumbled across the “problem” of trimming the terminating character from a null-terminated string. I started getting all creative about it, but it soon became quite a mess (code-wise), so I that down and had a re-think. This is how I ultimately ended up doing it. (more…)
In dealing with data transferred between different operating systems, we often come across the irritating phenomenon of, what might appear as, a file without any spaces in them. This is of course because of different end of line (EOL) characters, and I’m going to show you a quick and easy way of using PowerShell to “fix” these for Windows. (more…)
If you have worked with PowerShell for a while, chances are you are familiar with Enums. If you have also worked with more traditional programming languages you definitely are familiar with Enums!
Enums can have custom attributes, and one such attribute is the topic this quick tip; the FlagsAttribute! (more…)