PowerShell Kieran Jacobsen PowerShell Kieran Jacobsen

Installing PowerShell on Orange PI One

Hi Everyone,

I was a long-term user of Monitor-io, and I was saddened to hear that had planned to shutdown their services on April 15, 2023. I was excited to hear that unlike many IoT vendors, Monitor-io had made the decision to provide an option for their customers to continue to use their devices in a standalone manner.

A Monitor-io showing its local IP address

The Monitor-io unit consists of an Orange PI One and an LCD screen. The Orange Pi One is features an ARM processor – H3 Quad-core Cortex-A7, 512mb of DDR, 10/100mpbs Ethernet, and supports up to 32Gb of storage via micro-SD card. The Cortex-A7 is based off the 32bit ARMv7 instruction set, for those familiar with the Raspberry Pi, this is the same instruction set as the Pi 2 Model B.

Monitor-io provided an image based upon Armbian, and a shell script (netmonitor.sh) that provides basic ping checks to a list of targets listed in the targets.conf file using fping. The script updates the LCD display based upon the results from fping.

Before I started, I wanted to get PowerShell running. PowerShell doesn’t officially support the Orange Pi One, but there is a shared architecture, so I hopped for the best managed to get PowerShell 7.3.4 up and running.

The process was very similar to Installing on Raspberry Pi OS, use the following shell commands to download, and install the package. You will need to change the URL to match the right PowerShell version that you want to install.

###################################
# Prerequisites

# Update package lists
sudo apt-get update

###################################
# Download and extract PowerShell

# Grab the latest tar.gz
wget https://github.com/PowerShell/PowerShell/releases/download/v7.3.4/powershell-7.3.4-linux-arm32.tar.gz

# Make folder to put powershell
mkdir ~/powershell

# Unpack the tar.gz file
tar -xvf ./powershell-7.3.4-linux-arm32.tar.gz -C ~/powershell

###################################
# Optional - Create a symbolic link to start PowerShell without specifing path to pwsh bindar
sudo ln -s ~/powershell/pwsh /usr/bin/pwsh

I haven't fully tested and validated that everything is working, however items like Invoke-WebRequest, and Invoke-RestMethod both appear to function correctly. Most other basic commands also seem to be running without any issues.

Read More
PowerShell, Communities Kieran Jacobsen PowerShell, Communities Kieran Jacobsen

Planet PowerShell Update: Mastodon, Twitter, and Pronoun Support

Over the last few weeks, I have been working on some new features in Planet PowerShell.

Mastodon Support

As more users make the move to Mastodon, I wanted to ensure that Planet PowerShell could continue to support the community.

You can now follow Planet PowerShell on Mastodon, @[email protected]. New posts are automatically tooted using the #PowerShell and #pwsh hashtags.

There is now support for authors to share their Mastodon handles. Authors will need to specify a value for the MastodonHandle property. I have already included some authors’ handles where I was following them. If you are a Planet PowerShell author and have made the transition to Mastodon, please ensure you update your author .cs file.

Including Mastodon support was a simple decision for me, and I am extremely thankful that I have made the decision considering recent announcements (see Twitter Support). As part of the change, I needed to update from Font Awesome v4 to v6, you may notice some icons have slightly changed on the website.

Twitter Support

With the extremely unfortunate decision by Twitter to no longer provide free access to their API, Zapier have notified their users that they anticipate their integration to stop working. Planet PowerShell uses Zapier to post to Twitter, Facebook, and Mastodon.

At this stage, it appears that when Twitter’s API change occurs, the @Planetpshell Twitter will also go silent. This is incredibly disappointing. Over the years, Planet PowerShell has gained 3,358 followers, posted hundreds or blog posts and had tens of thousands of impressions each month.

If an alternative solution for posting becomes available, then we may see Planet PowerShell return to Twitter, until then, I recommend everyone follows the RSS, Mastodon, or Facebook page.

Pronoun Support

It is extremely important to me that Planet PowerShell is an inclusive community. Authors now have the option to specify their pronouns. Simply update the Pronouns property in your author .cs file, and the pronouns will be displayed on the Authors page. This is optional, but I highly encourage all authors to include their pronouns.

Analytics & Cookies

Analytics has been a big challenge with Planet PowerShell. I rely on analytics and usage information as part of my Microsoft MVP reporting; making use of a mix of values provided by Google Analytics and Cloudflare’s built in analytics. This isn’t a perfect solution, particular as there isn’t an effective measure for the RSS feed.

In the past, my side projects like Planet PowerShell have often influenced my work projects. Recently, the flow has reversed. After some discussions around GDPR and Analytics, I decided to make some changes to Planet PowerShell.

Planet PowerShell didn’t have a cookie consent mechanism, something that was a potential issue. CookieBot has a free tier for smaller websites, it works by scanning the website and collecting information on all the cookies in use; you just include a small snippet of code from CookieBot, and it will take care of prompting users to accept or reject various cookies. Due to the small number of pages, Planet PowerShell fits perfect in the free tier, with setup and testing being very quick and easy.

As I was implementing CookieBot, I discovered an issue with Planet PowerShell that goes back to the original fork from Planet Xamarin. When I made the fork, I made sure to update Google Analytics and Google Maps codes and keys, but I missed something. Planet Xamarin also made use of Clicky, a more privacy-friendly website analytics provider. I have update Planet PowerShell to use its own Clicky ID.

Lastly, I have also implemented Heap analytics. Heap analytics platform is one of the easiest to understand, and provides information in a concise manner. It still doesn’t help with the RSS feed, I hope will give me a better understanding of the interactions on the Planet PowerShell website.

My aim is to review the usefulness of the information provided by Google Analytics, Clicky, Heap and Cloudflare, and remove those who aren’t useful long term.

Looking for more authors!

I want to grow the number of authors whose content is aggregated as part of the Planet PowerShell feed. If you are an author, please take the time to add your blog. If you need help, feel free to message me and I will be able to assist.

Finally, I want to thank everyone of the support over the years with Planet PowerShell. Things have come a long way over the last 7 years. I can’t wait to see how things change in the next 7 years!

Read More
PowerShell Kieran Jacobsen PowerShell Kieran Jacobsen

PowerShell CSV Quick Hack – Redistributing Columns in CSV Files

These days, I spend much of my time working with spreadsheets or manipulating data that has come from systems in the form of CSV files.

This week I ran into an interesting issue where I ended up using some PowerShell tricks to change the structure of the data into a more useful format.

I found myself with a CSV file with the columns: Sender, Recipient, Recipient2, Recipient3… all the way to Recipient24. The file looked like this:

The original CSV file I was working with

Every row had a value for Sender and Recipient, however only some rows had values for Recipient2 and onwards.

What I needed was a list of Sender and Recipient, removing the other Recipient* columns and making them new entries. What I needed was a list that looked like this one:

The CSV layout I wanted

I am not an Excel guru, but I am handy with PowerShell, so I decided that I would clean this up with PowerShell.

My original thought was this process:

  1. Import the CSV file using import-csv
  2. Have a foreach loop that looked at each entry in the CSV file, and created new entries as follows.

My code looked like this:

$OriginalCSV = import-csv 'original.csv'
$NewCSV = @()
Foreach ($item in $OriginalCSV) {
    $NewCSV = $NewCSV + [PSCustomObject]@{Sender = $item.Sender; Recipient=$item.Recipient}
    $NewCSV = $NewCSV + [PSCustomObject]@{Sender = $item.Sender; Recipient=$item.Recipient2}
    $NewCSV = $NewCSV + [PSCustomObject]@{Sender = $item.Sender; Recipient=$item.Recipient3}
    $NewCSV = $NewCSV + [PSCustomObject]@{Sender = $item.Sender; Recipient=$item.Recipient4}
    $NewCSV = $NewCSV + [PSCustomObject]@{Sender = $item.Sender; Recipient=$item.Recipient5}
    # ...
    $NewCSV = $NewCSV + [PSCustomObject]@{Sender = $item.Sender; Recipient=$item.Recipient23}
    $NewCSV = $NewCSV + [PSCustomObject]@{Sender = $item.Sender; Recipient=$item.Recipient24}
}
$NewCSV | Export-Csv -Path 'new.csv'

This code does what I needed, but it is far from perfect. I have copy-pasted the same code; it does not look very re-usable.

How could I make this code more reusable?

With PowerShell, I can dynamically build a reference to an object’s methods and members as so:

$Value=2
$item."Recipient$Value"

By adding a for loop, I can now pass throw each of the Recipient* columns without resorting to copy-pasting code. This allowed me to simplify my code down to:

$OriginalCSV = import-csv 'original.csv'
$NewCSV = @()

Foreach ($item in $OriginalCSV) {
    $NewCSV = $NewCSV + [PSCustomObject]@{Sender = $item.Sender; Recipient=$item.Recipient}

    for ($ii = 2; $ii -le 24; $ii++) {
        if ($item."Recipient$ii" -ne '') {
            $NewCSV = $NewCSV + [PSCustomObject]@{Sender = $item.Sender; Recipient=$item."Recipient$ii"}
        }
    }
}
$NewCSV | Export-Csv -Path 'new.csv'

Till next time,

Kieran

Read More
PowerShell, Security Kieran Jacobsen PowerShell, Security Kieran Jacobsen

Mitigating IE Zero-Day (CVE-2020-0674/ADV200001) with PowerShell and Intune

Microsoft published a security advisory (ADV200001) containing mitigations against an actively exploited zero-day remote code execution (RCE) vulnerability in Internet Explorer. At time of writing, there is no patch for the vulnerability. Microsoft is expecting to release a patch as part of the usual Patch Tuesday (Wednesday for some of us) cycle.

Microsoft has provided some mitigation steps that can be applied; however, they only recommend taking these steps if there is an indication you are under elevated risk. One of the problems with the mitigation steps is that you MUST revert the changes before you can install any future updated.

The mitigations also come with some side-effects; their impact might be too much for some organisations. Side-effects include:

  • Printing to HP printers and other USB printers mail fail.
  • Windows Media Player is reported to break on playing MP4 files.
  • Sfc.exe will break.
  • Printing to "Microsoft Print to PDF" is reported to break.
  • Proxy automatic configuration scripts (PAC scripts) may not work. For me, I couldn’t imagine managing some enterprise environments without PAC scripts. That alone would be a good reason to not deploy these fixes.

If after all of this, you want to still apply these mitigations. I put together some quick guidance for their implementation with Intune.

Enabling the mitigations

  1. Get a copy of the Enable-ADV200001.ps1 script from my GitHub repository.
  2. Sign-in to the Microsoft Endpoint Manager Admin Center.
  3. Select Devices > PowerShell scripts > Add.
  4. In Basics, enter the Name: Enable IE Mitigations for ADV200001, and select Next:
  5. In Script settings, browse to where you downloaded the Enable-ADV200001.ps1 script, leave everything else at their default settings, and select Next:
  6. Select Scope tags. Scope tags are optional, if you don’t use this feature, select Next.
  7. Select Assignments > Select groups to include. Select with groups this script should be applied to, select Next.
  8. In Review + add, a summary is shown of the settings you configured. Select Add to save the script. When you select Add, the policy is deployed to the groups you chose.

Disabling the mitigations

  1. Get a copy of the Disable-ADV200001.ps1 script from my GitHub repository.
  2. Sign-in to the Microsoft Endpoint Manager Admin Center.
  3. Select Devices > PowerShell scripts > Add.
  4. In Basics, enter the Name: Disable IE Mitigations for ADV200001, and select Next:
  5. In Script settings, browse to where you downloaded the Disable-ADV200001.ps1 script, leave everything else at their default settings, and select Next:
  6. Select Scope tags. Scope tags are optional, if you don’t use this feature, select Next.
  7. Select Assignments > Select groups to include. Select with groups this script should be applied to, select Next.
  8. In Review + add, a summary is shown of the settings you configured. Select Add to save the script. When you select Add, the policy is deployed to the groups you chose.

More guidance can be found here Use PowerShell scripts on Windows 10 devices in Intune

Just remember that before your next patch cycle, you need to disable the mitigations, otherwise the updates will fail.

Read More
PowerShell Kieran Jacobsen PowerShell Kieran Jacobsen

[Updated Module] Posh-SYSLOG v4.1.5 has been released

A new version of the [Posh-SYSLOG](https://github.com/poshsecurity/AzurePublicIPAddresses/) module has been released. The purpose of this update is to provide better support when running on PowerShell Core.

A new version of the Posh-SYSLOG module has been released.

The purpose of this update is to provide better support when running on PowerShell Core. This module removes the dependencies on Get-CIMInstance that isn't available on PS Core (at least on MacOS and Linux).

This code will not work correctly on PSCore 6 on WSL at this stage due to an issue in the underlying .Net Core version.

I have also switched to YAML builds and added additional test cases. I need to write a few more test cases for the new functionality.

Getting the Module

If you have never used the module before, the easiest way to get Posh-SYSLOG is through the PowerShell Gallery:

PS> Install-Module -Name Posh-SYSLOG

If you already have the module installed, you can update the module from the PowerShell Gallery with:

PS> Update-Module -Name Posh-SYSLOG

You can also download the release from the module’s GitHub Releases page.

Found an issue? Then raise any bugs or feature requests via GitHub Issues.

Read More
Azure, PowerShell Kieran Jacobsen Azure, PowerShell Kieran Jacobsen

What’s Coming up with AzurePublicIPAddresses

Just a brief post to discuss the future of the AzurePublicIPAddresses PowerShell module.

Just a brief post to discuss the future of the AzurePublicIPAddresses PowerShell module.

I still believe there is a community need for this module, and as such, am going to continue to support it. The module fills some gapes in the Azure space, allowing for IT professionals to easily determine which addresses belong to each region. I have spoken to a few people who have used the module to help in managing their on-premises firewall rules, etc., they have spoke of how this module has helped them. I want to continue to support them. What is clear, is that I will need to invest some time in making some considerable updates to the module. These are to ensure that the module continues to function.

Microsoft has now flagged that the XML based Microsoft Azure Datacenter IP range files are now deprecated. They will stop updating these files on 2020-06-30. The new mechanism for getting updates is the Azure IP Ranges and Service Tags files. These are JSON formatted and include a break down of IP ranges by region and service. This opens more functionality to the users of the AzurePublicIPAddresses module, allowing the choice of IP ranges based on region and service. Another benefit is support for the US Government Cloud Regions.

I don’t expect it to take me a year to update the module, however with the file format changes, and some of the structural changes in the file, it might take a little effort to ensure that everything works as expected. The plan is to have a beta version available later in the year. My goal is to release version 2, with this and other updates, by the end of the year.

In the meantime, I will continue to support the current module, releasing updates when new regions are made available.

Read More
PowerShell, Azure Kieran Jacobsen PowerShell, Azure Kieran Jacobsen

[Updated Module] AzurePublicIPAddresses v1.0.14 has been released

A new version of the AzurePublicIPAddresses module has been released. This includes support for 8 new regions: UAE, South Adrican, Chile, and Brazil.

Azure Region Map

A new version of the AzurePublicIPAddresses module has been released. This includes support for 8 new regions: UAE, South African, Chile, and Brazil. For more information see the Change Log.

Getting the Module

If you have never used the module before, the easiest way to get AzurePublicIPAddresses is through the PowerShell Gallery:

PS> Install-Module -Name AzurePublicIPAddresses

If you already have the module installed, you can update the module from the PowerShell Gallery with:

PS> Update-Module -Name AzurePublicIPAddresses

You can also download the release from the module’s GitHub Releases page.

Found an issue? Then raise any bugs or feature requests via GitHub Issues.

Read More
DevOps, PowerShell, Azure, Presentations, Security Kieran Jacobsen DevOps, PowerShell, Azure, Presentations, Security Kieran Jacobsen

Tickets now available: 2019 Global Azure Bootcamp Melbourne

I am excited to announce that tickets are now avavailable for the Global Azure Bootcamp - Melbourne! This year the bootcamp will be on Saturday 27th of April 2019.

Global Azure Bootcamp Logo

Global Azure Bootcamp Logo

I am excited to announce that tickets are now avavailable for the Global Azure Bootcamp - Melbourne! This year the bootcamp will be on Saturday 27th of April 2019.

The Global Azure Bootcamp is a free one-day global event organised entirely by users in the community for Azure users around the world who gathered to share essential Azure and Cloud Computing skills and ideas at the seventh annual Global Azure Bootcamp in 2019. We are hosting this event in Melbourne, Australia, but there are many locations, in fact more than 100 other locations worldwide, where the Global Azure Bootcamp will be hosted on the same day.

This is an educational event, and we want it to be an opportunity for everyone to gain new skills. The focus of the event is to teach essential Azure skills to anyone in the technology community who wants to advance their cloud knowledge and the goal of the event is to show people the benefits of Azure while strengthening the Azure community.

Tickets are available via EventBrite, and typically sell out very quickly. We will be maintaining a waiting list once we run out of tickets.

Read More