Skip to content

Commit

Permalink
[Publish] - Update WinSCP Core to 6.3.3. Correct dynamic param to pro…
Browse files Browse the repository at this point in the history
…perty mappings in New-WinSCPSession and New-WinSCPSessionOption. Add -DisableVersionCheck and -ExecutablePath to New-WinSCPSession per issue #160. Update Help files.
  • Loading branch information
tomohulk committed May 15, 2024
1 parent 5c82818 commit b296426
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
workflow_dispatch:

env:
ModuleVersion: 6.3.2.0
ModuleVersion: 6.3.3.0
ReleaseNotes: ${{ github.event.head_commit.message }}

# A workflow run is made up of one or more jobs that can run sequentially or in parallel.
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion WinSCP/Public/New-WinSCPSession.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
}

$keys = ($PSBoundParameters.Keys).Where({
$_ -in (($session | Get-Member -MemberType Property).Name)
$_ -in ($session | Get-Member -MemberType Property | Select-Object -ExpandProperty Name)
})

foreach ($key in $keys) {
Expand Down
23 changes: 14 additions & 9 deletions WinSCP/Public/New-WinSCPSessionOption.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ function New-WinSCPSessionOption {
)

begin {
$sessionOptions = New-Object -TypeName WinSCP.SessionOptions
$sessionOption = New-Object -TypeName WinSCP.SessionOptions
}

process {
$shouldProcess = $PSCmdlet.ShouldProcess(
$sessionOptions
$sessionOption
)
if ($shouldProcess) {
# Convert PSCredential Object to match names of the WinSCP.SessionOptions Object.
Expand Down Expand Up @@ -154,17 +154,22 @@ function New-WinSCPSessionOption {
Select-Object -ExpandProperty ProviderPath
}

# Enumerate each parameter.
try {
$sessionOptionObjectProperties = $sessionOptions |
Get-Member -MemberType Property |
Select-Object -ExpandProperty Name
# Enumerate each parameter.
foreach ($parameter in ([System.Management.Automation.CommandMetadata]::new($MyInvocation.MyCommand).Parameters.GetEnumerator())) {
if (-not ($PSBoundParameters.ContainsKey($parameter.Key))) {
if ($value = $ExecutionContext.SessionState.PSVariable.GetValue($parameter.Key)) {
$PSBoundParameters[$parameter.Key] = $value
}
}
}

$keys = ($PSBoundParameters.Keys).Where({
$_ -in $sessionOptionObjectProperties
$_ -in ($sessionOption | Get-Member -MemberType Property | Select-Object -ExpandProperty Name)
})

foreach ($key in $keys) {
$sessionOptions.$key = $PSBoundParameters.$key
$sessionOption.$key = $PSBoundParameters.$key
}
} catch {
$PSCmdlet.ThrowTerminatingError(
Expand All @@ -179,7 +184,7 @@ function New-WinSCPSessionOption {
)
}

Write-Output -InputObject $sessionOptions
Write-Output -InputObject $sessionOption
}
}
}

0 comments on commit b296426

Please sign in to comment.