Looking back at 2020, Four Months Of Blogging

A look back on four months of blogging and engaging the PowerShell community

The year is coming to an end, with all its ups and downs 2020 surely was challenging to say the least. I wanted to take this time to openly reflect on my first couple months of blogging and what the future holds for ps1.guru PS> $firstPost = Get-Date -Year 2020 -Month 09 -Day 13 PS> $latestPost = Get-Date -Year 2020 -Month 12 -Day 22 PS> New-TimeSpan $firstPost $latestPost | Select-Object Days Days ---- 100 So, how are things going? [Read More]

My Stand On Affiliate Links

What I think about affiliate links

Lets talk about affiliate links for a moment. TLDR: I will use affiliate links where it is possible for me, wich isn’t often to be honest Lets dig into it, starting with some basic assumptions I am making: Most of my posts are technical content where I do not recommend any products or services, so there are no opportunities for affiliate links to begin with In posts where I reference a product or service I do so because I think it is great and I really want to recommend it There are no negative effects for the reader when using my affiliate links There are benefits for me when you use the affiliate link, either monetary or in credit with the service - This helps me keep this blog up and running for everyone to benefit Given those assumptions I don’t see any reason why I should not use affiliate links. [Read More]

Super-Charged Cmdlet Aliases

It works like magic, but it works - Bring your aliasing to a whole other level!

Backstory I recently wrote a post about PowerShell Aliasing for the folks over at ScriptRunner. The one issue I had while researching for this post was this: You can not create a alias for a function and overwrite one of it’s parameters at the same time while keeping nice features like tab-complete. For a concrete example of this visit please look at the original post. At the end of the post I asked if anyone had a solution to this problem - and the internet delivered! [Read More]

Why You Want To Install PowerShell On Windows

Why installing PowerShell on Windows may actually be a good idea

Q: Wait a minute! Don’t I already have PowerShell? A: Yes. However you may want to continue reading because things are never as simple as they appear. The PowerShell version you have installed on Windows 10 is 5.X, Microsoft even says so in their own documentation. On the initial release of Windows 10, with automatic updates enabled, PowerShell gets updated from version 5.0 to 5.1. If the original version of Windows 10 is not updated through Windows Updates, the version of PowerShell is 5. [Read More]

Collections and Randomization

Randomize Collections in PowerShell

Randomizing a collection is useful in a variety of situations and in most languages it is fairly straight forward. For example Python my_list = range(1,20) random.shuffle(my_list) PHP $numbers = range(1, 20); shuffle($numbers); In PowerShell this works a bit differently. Before 7.1 PS> @(1,2,3) | Sort-Object {Get-Random} 3 1 2 PS> "abc".ToCharArray() | Sort-Object {Get-Random} a c b Well, how does that work? Sort-Object allows us to sort the incoming collection based on a script block. [Read More]

How To Grep With PowerShell

It's just like Bash, but more powerful!

Filtering data, from log or config files to data returned by an api, is an important operation to remove noise from it and make further analysis possible. In Bash most would gravitate towards grep, egrep or awk. Classic examples would be looking at your history $ history | grep ssh ssh marco@ ssh deploy@ ssh admin@ looking for errors in a log $ cat /var/log/app.log | grep error 2020-09-30 09:01:17 error: twitter api responded with 403 2020-09-30 09:16:05 error: secret plan to take over the world failed grep $ grep api app. [Read More]

How To Tail With PowerShell

How to replace tail in PowerShell

Printing the last or first, few lines of a file is a common operation in day to day operations. On Linux most people will, without thinking twice, use tail and it’s counterpart head to achieve this. It’s man page1 describes tail simply like this Print the last 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name. Lets take a look at some common tail operations and how to reproduce them with PowerShell. [Read More]

Bash Utilities In Powershell

Replacing common bash utilities in PowerShell

Whats the first thing coming to mind when seeing a command line? For most people it is Linux, be it Ubuntu, Debian or RedHat. And it is completely understandable. A big part of our industry has a background in Linux and sees it as the superior system for quick scripts and the like. In this series I want to challenge this notion. PowerShell can compete with, an in some cases outperform, the quick scripts and common daily tasks done in Linux shells. [Read More]

Hello World

Who am I and what to expect on this blog

$arguments = @{ Name = "mkamner" FullName = "Marco Kamner" Description = "Automate all the things!" Password = $mySecret } New-LocalUser @arguments My Work On days I work at a medium sized cloud provider in germany. My history is in Windows Server and Exchange Administration but I have since transitioned to designing and implementing automation and wrangling data from one place to the other - commonly referred to as reporting. [Read More]