Skip to content

Commit 05c469a

Browse files
Merge pull request #3 from FriedrichWeinmann/development
winPS Fixes
2 parents bcebc36 + 7842e4f commit 05c469a

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

PSNative/PSNative.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
RootModule = 'PSNative.psm1'
55

66
# Version number of this module.
7-
ModuleVersion = '1.0.1'
7+
ModuleVersion = '1.0.2'
88

99
# Supported PSEditions
1010
# CompatiblePSEditions = @()

PSNative/functions/Invoke-NativeCommand.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,18 @@
6767
}
6868
$info.WorkingDirectory = $resolved.Path
6969
}
70-
foreach ($entry in $ArgumentList) { $info.ArgumentList.Add($entry) }
70+
if ($global:PSVersionTable.PSVersion.Major -lt 6) {
71+
$info.UseShellExecute = $false
72+
$info.Arguments = $ArgumentList -join " "
73+
}
74+
else {
75+
foreach ($entry in $ArgumentList) { $info.ArgumentList.Add($entry) }
76+
}
7177

7278
$info.RedirectStandardError = $true
7379
$info.RedirectStandardOutput = $true
7480

81+
7582
if ($Credential) {
7683
$info.Password = $Credential.Password
7784
$networkCred = $Credential.GetNetworkCredential()

PSNative/internal/scripts/class-nativeprocess.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@
3333
$info = [System.Diagnostics.ProcessStartInfo]::new()
3434
$info.FileName = $this.Name
3535
if ($this.WorkingDirectory) { $info.WorkingDirectory = $this.WorkingDirectory }
36-
foreach ($entry in $this.ArgumentList) { $info.ArgumentList.Add($entry) }
36+
if ($global:PSVersionTable.PSVersion.Major -lt 6) {
37+
$info.UseShellExecute = $false
38+
$info.Arguments = $this.ArgumentList -join " "
39+
}
40+
else {
41+
foreach ($entry in $this.ArgumentList) { $info.ArgumentList.Add($entry) }
42+
}
3743

38-
if ($global:PSVersionTable.PSVersion.Major -lt 6) { $info.UseShellExecute = $false }
3944
$info.RedirectStandardInput = $true
4045
$info.RedirectStandardError = $true
4146
$info.RedirectStandardOutput = $true

0 commit comments

Comments
 (0)