Skip to content

Commit e2f1aaf

Browse files
Update install-dbatools-library.ps1
1 parent 5301127 commit e2f1aaf

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

.github/scripts/install-dbatools-library.ps1

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,33 @@ function Install-FromGitHubRelease {
180180
if ($PSVersionTable.Platform -eq 'Unix') {
181181
$installBasePath = '/usr/local/share/powershell/Modules'
182182
} else {
183-
$installBasePath = "$env:ProgramFiles\PowerShell\Modules"
183+
# Windows - handle both PowerShell editions
184+
if ($PSVersionTable.PSEdition -eq 'Core') {
185+
$installBasePath = "$env:ProgramFiles\PowerShell\Modules"
186+
} else {
187+
# Windows PowerShell 5.1
188+
$installBasePath = "$env:ProgramFiles\WindowsPowerShell\Modules"
189+
}
184190
}
185191
} else {
186192
if ($PSVersionTable.Platform -eq 'Unix') {
187193
$installBasePath = "$env:HOME/.local/share/powershell/Modules"
188194
} else {
189-
$installBasePath = "$env:USERPROFILE\Documents\PowerShell\Modules"
195+
# Windows - handle both PowerShell editions
196+
if ($PSVersionTable.PSEdition -eq 'Core') {
197+
$installBasePath = "$env:USERPROFILE\Documents\PowerShell\Modules"
198+
} else {
199+
# Windows PowerShell 5.1
200+
$installBasePath = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules"
201+
}
190202
}
191203
}
192204

193205
# Install directly to module directory without version subdirectory for preview versions
194206
$finalInstallPath = Join-Path -Path $installBasePath -ChildPath $ModuleName
195207

196208
# Create installation directory
209+
Write-Log "Module base path: $installBasePath"
197210
Write-Log "Installing to: $finalInstallPath"
198211
if (-not (Test-Path (Split-Path $finalInstallPath))) {
199212
New-Item -Path (Split-Path $finalInstallPath) -ItemType Directory -Force | Out-Null
@@ -287,6 +300,8 @@ try {
287300

288301
Write-Log "Target version: $requiredVersion"
289302
Write-Log "Installation scope: $Scope"
303+
Write-Log "PowerShell Edition: $($PSVersionTable.PSEdition)"
304+
Write-Log "PowerShell Version: $($PSVersionTable.PSVersion)"
290305

291306
# Check if module is already installed (unless Force is specified)
292307
if (-not $Force) {

0 commit comments

Comments
 (0)