The PowerShell Team released the v6.0.0-rc version of PowerShell 6 Core. The Release notes sounds interesting and PowerShell Core is a cross-platform (Windows, Linux, and macOS) experience.
The good:
Great to have the same, more or less, consistent Shell available on all my platforms.
The Bad:
Overall it it a solid release! And I recommend everyone to install it.
Some minor things:
- The Name change from PowerShell to pwsh still causes some problems for me.
- Not everything is available on non Windows platforms. I miss a few things on my MacOS systems.
- System wide modules are installed within the PowerShell (versioned) directory. So they are not available after the update/upgrade. This is different to Windows Desktop versions.
The Ugly:
Somethings are (still?) a bit ugly!
- The Module Repository trust doesn’t work on Linux (Cents 7 in my case)
PS /root> clear
PS /root> Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
PS /root> Get-PSRepository -Verbose
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2/'; IsTrusted = 'True'; IsRegistered = 'True'.
Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Trusted https://www.powershellgallery.com/api/v2/
PS /root> Install-Module -ErrorAction Stop -Name Plaster
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):
Installation on Linux
I changed my installation from direct download to the (preferred) Package Repository mode.
#!/bin/bash
# Cleanup (optional)
# Remove alle older beta installations
sudo rm -R /opt/microsoft/powershell/6.0.0-beta.*
# Get the Yum data
curl https://packages.microsoft.com/config/rhel/7/prod.repo | tee /etc/yum.repos.d/microsoft.repo
# Install latest PowerShell Core
yum install -y powershell
# Mitigate the latest name change of the executable
sudo ln /bin/pwsh /usr/local/bin/powershell
I use Munki with AutoPkg to install software on my MacOS based systems. But I tried the Homebrew installation on one of my systems as described. I use Homebrew a lot, but normally I don’t use cask (whenever possible). Mostly because it some bugs break my regular Homebrew workflows.
Install some basic modules
Due to the fact, that modules are installed within the (versioned) PowerShell Core directory, they are gone after the upgrade! So I created a quick and dirty script to install all the basic modules that I would like to have on all systems:
#requires -Version 2.0 -Modules PowerShellGet
<#
.SYNOPSIS
Install some base PowerShell modules
.DESCRIPTION
Install the PowerShell base modules that I would like to have on all new systems.
.EXAMPLE
PS C:\> .\posh_mods.ps1
.NOTES
Works on Windows, Linux and MacOS.
#>
begin
{
# set installation trust, if neededd.
$null = (Set-PSRepository -Name PSGallery -InstallationPolicy Trusted)
# force to install latest Pester module
$null = (Install-Module -ErrorAction SilentlyContinue -Name Pester -force)
# list of new modules
$ModuleList = @(
'posh-git',
'platyPS',
'PSScriptAnalyzer',
'nScriptAnalyzerRules',
'ScriptCop',
'Psst',
'PowerShellGuard',
'Posh-SSH',
'Plaster',
'PesterHelpers',
'PScribo',
'PSScaffold',
'ModuleBuild',
'InvokeBuild',
'GitHubReleaseManager',
'Format-Pester',
'BitBucketCloud'
)
}
process
{
# do the loop
foreach ($ModuleItem in $ModuleList)
{
try
{
Write-Verbose -Message "Install Module: $ModuleItem"
# install
$null = (Install-Module -ErrorAction Stop -Name $ModuleItem)
Write-Verbose -Message "Installed Module: $ModuleItem"
}
catch
{
# Whoooops
Write-Warning -Message "Failed to install Module: $ModuleItem"
}
}
}
end
{
Write-Verbose -Message 'Done...'
}
Nothing fancy, but it should do the job! You might want to change the Module list in the $ModuleList variable.