Context
PowerShell was… initially a Windows component only, known as Windows PowerShell, it was made open-source and cross-platform on August 18, 2016, with the introduction of PowerShell Core. The former is built on the .NET Framework, the latter on .NET (previously .NET Core). PowerShell – Wikipedia
- Differences between Windows PowerShell 5.1 and PowerShell 7.x – PowerShell | Microsoft Learn
- What is PowerShell? – PowerShell | Microsoft Learn
- What is Windows PowerShell? – PowerShell | Microsoft Learn
- The latest version is Windows PowerShell 5.1. Microsoft is no longer updating Windows PowerShell with new features. Support for Windows PowerShell is tied to the version of Windows you are using.
As Microsoft is no longer updating Windows PowerShell with new features it makes sense to use the procedure for ‘Developing modern modules‘ which are (hopefully) portable to any OS running PowerShell.
If creating a new module, the recommendation is to use the .NET CLI.
Create module from ‘Standard Template’
# Install .NET SDK
> winget install Microsoft.DotNet.SDK.8
Found Microsoft .NET SDK 8.0 [Microsoft.DotNet.SDK.8] Version 8.0.204
…
Successfully installed
# Install a ‘template library to generate a simple PowerShell module’
> # Install .NET SDK
> winget install Microsoft.DotNet.SDK.8
Found Microsoft .NET SDK 8.0 [Microsoft.DotNet.SDK.8] Version 8.0.204
…
Successfully installed
# Install a ‘template library to generate a simple PowerShell module’
## Requires NuGet source enabled
> dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org
> dotnet new install Microsoft.PowerShell.Standard.Module.Template
# Create a new module project
> mkdir myPSModule; cd .\myPSModule
> dotnet new ps5module