Closed BohrenAn closed 1 year ago
That's expected, this is for PowerShell 7+.
See:
The specific error you see is caused by the ternary operator not being implemented in Windows PowerShell:
Thanks for the explanation and the Links.
That's expected, this is for PowerShell 7+.
In this case the module should not load under Powershell v5.1.
Is it possible to backport this to Powershell v5.1? My use case is use this with a Bicep template to deploy a VM. The Microsoft image does not come with Powershell 7 pre-installed
@vandre Did you try the Microsoft.PowerShell.PSResourceGet Module? https://blog.icewolf.ch/archive/2023/10/15/sucessor-of-powershellget-called-psresourceget-is-ga/ That has improved the Installation of PowerShell Modules a lot - not quite as fast as ModuleFast but helps a lot. Regards Andres
@BohrenAn Thanks Andres. It is indeed faster. One thing of note I had to Install the Nuget Package Provider manually because it is not available OOB with the Windows Server 2019 Azure VM image
I ended up with the following script:
#Requires -RunAsAdministrator
[CmdletBinding()]
param(
[Parameter (Mandatory = $true)]
[string] $pat
)
$IsVerbose = $VerbosePreference -eq "Continue"
$ErrorActionPreference = "Stop";
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (-Not (Get-Module -ListAvailable -Name Microsoft.Powershell.PsResourceGet)) {
Write-Verbose "Installing PSResourceGet"
Get-PackageProvider -Name NuGet -ForceBootstrap
Install-Module -Name Microsoft.PowerShell.PSResourceGet -Repository PsGallery -Force -AllowClobber
}
$patToken = $pat | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential("PAT", $patToken)
Register-PSResourceRepository -Trusted -Name AzRepo -Uri 'https://pkgs.dev.azure.com/MyOrg/MyProject/_packaging/MyFeed/nuget/v3/index.json' -Force
Install-PSResource MyPackage -Repository AzRepo -Credential $credential -Scope AllUsers -Verbose:$IsVerbose
Hi There
I've tested it with PowerShell 5.1 and got an error
iwr bit.ly/modulefast | iex
iex : At line:21 char:36
Regards Andres