Splitting the PowerShell PSModulePath Cross-Platform

The $env:PSModulePath environment variable contains a list of directory locations that PowerShell searches to locate modules. $env:PSModulePath When you’re trying to determine what paths are part of the $env:PSModulePath environment variable in PowerShell, you’ll find that most examples split the results on the semicolon (;) character to return each path on a separate line. $env:PSModulePath -split ';' Another variation is to use the Split method instead of the operator. $env:PSModulePath.Split(';') Splitting on a semicolon was a great solution back in the day of Windows (only) PowerShell....

February 17, 2023 · 276 words · Mike F. Robbins

Sync VS Code Settings between Computers with Different User Profile Paths

You’re using Visual Studio Code (VS Code) on multiple computers and you’ve enabled the settings sync feature to synchronize your VS Code settings between computers. Some VS Code settings reference files in your user profile. This creates a problem because the path to your user profile is different between computers. These user profile path differences cause some VS Code extensions to generate errors because they’re unable to find the files specified in your settings....

February 10, 2023 · 334 words · Mike F. Robbins

Rendering Images in Markdown Preview of Hugo Site

Hugo is an open-source static site generator written in Go that’s optimized for speed, ease of use, and flexibility. Hugo is designed for creating blogs, documentation sites, and other types of websites quickly and efficiently. You’re using Hugo to host your blog or website. Because of Hugo’s file structure, your articles are located in /content/posts and your images are located in /static/images as shown in the following example: my-hugo-site/ ├── archetypes/ ├── content/ | └── posts/ ├── resources/ ├── static/ | └── images/ ├── themes/ Hugo renders the images in your articles correctly using !...

February 8, 2023 · 339 words · Mike F. Robbins

Enable PowerShell remoting on ArcoLinux

PowerShell is a cross-platform scripting language that runs on Windows, Linux, and macOS. ArcoLinux is a rolling release Linux distribution based on Arch Linux. Prerequisites ArcoLinux was installed using the ArcoLinuxL ISO with the easy installation option. The examples shown in this article were performed using Xfce Terminal. ArcoLinux was fully updated using the sudo pacman -Syu command. Installation Verify that you have PowerShell installed: pwsh --version If you receive the error: command not found, see Install PowerShell on ArcoLinux to install PowerShell....

August 25, 2022 · 712 words · Mike F. Robbins

Install the Hugo Static Site Generator on ArcoLinux

Hugo is a lightning-fast open-source static site generator that’s written in Go. ArcoLinux is a rolling release Linux distribution based on Arch Linux. Prerequisites ArcoLinux was installed using the ArcoLinuxL ISO with the easy installation option. The examples shown in this article were performed using Xfce Terminal. ArcoLinux was fully updated using the sudo pacman -Syu command. Installation I downloaded version 0.89.4 of Hugo extended. For the latest version or a different version, see the Hugo GitHub repo....

August 4, 2022 · 337 words · Mike F. Robbins

Install Visual Studio Code (VS Code) on ArcoLinux

Visual Studio Code (VS Code) is a powerful, lightweight, and cross-platform source code editor. ArcoLinux is a rolling release Linux distribution based on Arch Linux. Prerequisites ArcoLinux was installed using the ArcoLinuxL ISO with the easy installation option. The examples shown in this article were performed using Xfce Terminal. ArcoLinux was fully updated using the sudo pacman -Syu command. Installation You could use the pacman or paru command. I chose to use the pamac command....

July 28, 2022 · 218 words · Mike F. Robbins

Install PowerShell on ArcoLinux

PowerShell is a cross-platform scripting language that runs on Windows, Linux, and macOS. ArcoLinux is a rolling release Linux distribution based on Arch Linux. Like other Arch-based Linux distributions, ArcoLinux uses pacman for its package manager. Prerequisites ArcoLinux was installed using the ArcoLinuxL ISO with the easy installation option. The examples shown in this article were performed using Xfce Terminal. ArcoLinux was fully updated using the sudo pacman -Syu command. Your mileage may vary with other operating systems, versions, distributions, desktop environments, ISO’s, terminals, installation options, package managers, and versions of PowerShell....

June 30, 2022 · 347 words · Mike F. Robbins

Use PowerShell to determine the Windows version on DVD, ISO, or USB installation media

You’re preparing to load an operating system. You find installation media for an unknown version of Windows. It’s not labeled. How do you determine the version of Windows on the installation media? You can use the Get-WindowsImage cmdlet to determine the Windows version of installation media. This cmdlet is part of the Dism PowerShell module. It can be used with Windows PowerShell 5.1 and PowerShell 7 on Windows operating systems....

June 16, 2022 · 74 words · Mike F. Robbins

Using the conditional ternary operator for simplified if/else syntax in PowerShell 7

The conditional ternary operator is a feature added to PowerShell in version 7. You can use it as a simplified version of if/else. The syntax for the ternary operator takes three operands: A condition to evaluate followed by a question mark (?). An expression to execute if the condition is true, followed by a colon (:). And finally, an expression to execute if the condition is false. <condition-to-evaluate> ? <expression-to-execute-if-true> : <expression-to-execute-if-false> The examples in this blog article were tested using Windows 11 version 21H2, PowerShell version 7....

June 9, 2022 · 297 words · Mike F. Robbins

Formatting PowerShell 7 code like Kusto Query Language

An obscure feature that was added to PowerShell in version 7 is the ability to specify the pipe character on the next line similar to the syntax for Kusto Query Language (KQL). Get-Command -Name Get-Help, Get-Command, Get-Member -PipelineVariable results | Select-Object -ExpandProperty ParameterSets | Select-Object -ExpandProperty Parameters | Where-Object Aliases | Select-Object -Property @{label='CmdletName';expression={$results.Name}}, Name, Aliases | Sort-Object -Property CmdletName, Name -Unique | Format-Table -GroupBy CmdletName Pasting code in the PowerShell console with pipes at the beginning of lines only works when using Ctrl+V....

June 2, 2022 · 99 words · Mike F. Robbins

Format the output of a string in multiple columns with PowerShell

In my previous blog article, I used the PowerShell Format-Wide cmdlet to format the output of a string in multiple columns. While Format-Wide isn’t a command that I’ve used extensively, the behavior wasn’t what I expected. When you pipe object-based output other than a string from any PowerShell command to Format-Wide, it produces the desired results. Get-PSDrive | Format-Wide -Column 2 I’ll pipe the following to Get-Member to confirm that it’s a string....

May 26, 2022 · 229 words · Mike F. Robbins

Use the Abstract Syntax Tree (AST) to list parameters and variables in PowerShell functions

One thing I’ve missed during the past couple of years with virtual-only conferences is the hallway track. While at the PowerShell + DevOps Global Summit 2022, there was a discussion about using PascalCase for parameter names and camelCase for user-defined variables in your PowerShell functions. Specifying different casings depending on the usage seems like a great idea. Determining where you defined your variables would be self-explanatory. The only problem is you need something to verify that you’ve specified them in the correct case....

May 12, 2022 · 634 words · Mike F. Robbins