If you are running an older version of TLS and try to interact with the PowerShell Gallery you may see error messages like:

WARNING: Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’

The gallery officially only supports TLS 1.2, so you have to use this as a workaround:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 

Read more: https://devblogs.microsoft.com/powershell/powershell-gallery-tls-support



Advent Of Code 2019 Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

It’s pretty neat, give it a try!


Ok, this is not new or rocketsurgery, but it’s handy.

You can Google right out of the cmdline :¬) Just add this to your PowerShell profile

function google{
    if(-not($args.count -eq 0)){
        $searchstring = $args -join " " 
        $url = "https://www.google.com/search?q=$searchstring"
        $url = $url -replace "\s", "%20"
        Start-Process $Url
    }
}

While I’m just a ‘young padawan’ in the great world of regex, I really enjoy its power and like using it. I mainly use it for quick fixes and string manipulation. Here are some handy snippets I use:

  1. Have a long sausage of code seperated by semi-colon (;), try this:
Find: ;
Replace: $&\n

It will put each statement ending with ‘;’ in a new line and you can actually read the scipt now

Before:
coffee;coffee;coffee;

After:
coffee;
coffee;
coffee;
  1. Have a list and need to wrap it in quotes (“ “)? Easy.
Find: (.+)
Replace: "$1" # or '$1' if you need single quotes

It’ll basically wrap your strings with whatever you specify

Before:
coffee
coffee
coffee

After:
"coffee"
"coffee"
"coffee"
  1. Now let’s say you need those joint by comma in a line again
Find: \n
Replace: , # or whatever you need it to be separated with

It will join the lines back into one line separated by comma

Before:
"coffee"
"coffee"
"coffee"

After:
"coffee","coffee","coffee"
  1. How about them pesky blank lines? I gatchu fam
Find: ^(?:[\t ]*(?:\r?\n|\r))+
Replace: <blank>

Now stick with me, that’s where regex shows its true power and its crazy complexity Let’s look at the results.

Before:
"coffee"

"coffee"

"coffee"

After:
"coffee"
"coffee"
"coffee"

It does not look like much but if you have a larger script with hundrets of random blank lines in the code, it bothers me, this will fix it.

RegEx is stupid powerful, but with great power comes great resposibility.

Yes it’s complex and quite a beast to master but totally worth it and a great ROI I barely scratched the surface of what all Regular Expressions can do, but I love using it for small quick fixes as I just posted about. They used to take quite a lot of time, cleaning lists and stuff up before you can use them. I now I can spend more time on the actual code, rather than cleaning ‘dirty’ input up!

dotnet regular expression quick reference