Skip to content

Commit

Permalink
Merge pull request #111 from nyanhp/sendmodule
Browse files Browse the repository at this point in the history
Core compatibility
  • Loading branch information
nyanhp authored Aug 21, 2022
2 parents 7686b2e + 58a7291 commit f3c100c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions AutomatedLab.Common/Common/Public/Send-ModuleToPsSession.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ function Send-ModuleToPSSession

foreach ($s in $Session)
{
$sessionVersion = Invoke-Command -Session $s -ScriptBlock {$PSVersionTable.PSVersion}
[version]$sessionVersion = Invoke-Command -Session $s -ScriptBlock {
if ($PSEdition -eq 'core') {return ('{0}.{1}.{2}' -f $PSVersionTable.PSVersion.Major,$PSVersionTable.PSVersion.Minor,$PSVersionTable.PSVersion.Patch)}
$PSVersionTable.PSVersion
}

if ($Local:Module.PowerShellVersion -gt $sessionVersion)
{
Expand All @@ -137,7 +140,7 @@ function Send-ModuleToPSSession
Invoke-Command -Session $s -ScriptBlock {
$destination = if (-not $IsLinux -and -not $IsMacOs)
{
if ($PSVersionTable.PSVersion -ge ([version]::new(4,0)))
if ($PSVersionTable.PSVersion.Major -ge 4)
{
Join-Path -Path ([System.Environment]::GetFolderPath('ProgramFiles')) -ChildPath WindowsPowerShell\Modules
}
Expand Down

0 comments on commit f3c100c

Please sign in to comment.