From a4ee92da35a76d4b941df5a752d01feeb205c048 Mon Sep 17 00:00:00 2001 From: David Gardiner Date: Sat, 22 May 2021 16:17:32 +0930 Subject: [PATCH] Enable installing with PowerShell Core/7+ - Also ensure we install into 'AU' subdirectory. (Otherwise with Core at least, the install was ending up in C:\Program Files\PowerShell\Modules rather than C:\Program Files\PowerShell\Modules\AU) --- install.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/install.ps1 b/install.ps1 index bdffe5f0..9e1a7437 100644 --- a/install.ps1 +++ b/install.ps1 @@ -20,7 +20,12 @@ param( $ErrorActionPreference = 'Stop' $module_name = 'AU' -$module_dst = "$Env:ProgramFiles\WindowsPowerShell\Modules" + +if ($PSVersionTable.PSEdition -ne "Core") { + $module_dst = "$Env:ProgramFiles\WindowsPowerShell\Modules" +} else { + $module_dst = "$Env:ProgramFiles\PowerShell\Modules" +} Remove-Item -Force -Recurse "$module_dst\$module_name" -ErrorAction ignore if ($Remove) { remove-module $module_name -ea ignore; Write-Host "Module $module_name removed"; return } @@ -41,6 +46,8 @@ if (!(Test-Path $module_path)) { throw "Module path invalid: '$module_path'" } Write-Host "Module path: '$module_path'" +New-Item -ItemType Directory "$module_dst/$module_name" -ErrorAction Ignore | Out-Null + Copy-Item -Recurse -Force $module_path $module_dst $res = Get-Module $module_name -ListAvailable | Where-Object { (Split-Path $_.ModuleBase) -eq $module_dst }