@@ -43,6 +43,7 @@ $ModuleVersion = "1.5"
43
43
If ($env: PROCESSOR_ARCHITEW6432 -match ' 64' -and [IntPtr ]::Size -ne 8 ) {
44
44
Write-Warning ' 32-bit PowerShell session detected on 64-bit OS. Attempting to launch 64-Bit session to process commands.'
45
45
$pshell = " ${env: WINDIR} \sysnative\windowspowershell\v1.0\powershell.exe"
46
+ Write-Debug " Launch Context: $ ( $myInvocation | out-String ) "
46
47
If (! (Test-Path - Path $pshell )) {
47
48
Write-Warning ' SYSNATIVE REDIRECTION IS NOT AVAILABLE. Attempting to access 64bit binaries directly.'
48
49
$pshell = " ${env: WINDIR} \System32\WindowsPowershell\v1.0\powershell.exe"
@@ -53,15 +54,14 @@ public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);
53
54
"@
54
55
$Kernel32 = Add-Type - MemberDefinition $MethodSignature - Namespace " Kernel32" - Passthru - Name DisableWow64Redirection
55
56
[ref ]$ptr = New-Object System.IntPtr
56
- $Result = $Kernel32 ::Wow64DisableWow64FsRedirection($ptr ) # Now you can call 64-bit Powershell from system32
57
+ # $Result = $Kernel32::Wow64DisableWow64FsRedirection($ptr) # Now you can call 64-bit Powershell from system32
57
58
}
58
- Write-Debug " Launch Context: $ ( $myInvocation | out-String ) "
59
59
If ($myInvocation.Line ) {
60
- & " $pshell " - NonInteractive - NoProfile $myInvocation.Line
60
+ Write-Output ' &"$pshell" -NonInteractive -NoProfile $myInvocation.Line'
61
61
} Elseif ($myInvocation.InvocationName ) {
62
- & " $pshell " - NonInteractive - NoProfile - File " $ ( $myInvocation.InvocationName ) " $args
62
+ Write-Output ' &"$pshell" -NonInteractive -NoProfile -File "$($myInvocation.InvocationName)" $args'
63
63
} Else {
64
- & " $pshell " - NonInteractive - NoProfile $myInvocation.MyCommand
64
+ Write-Output ' &"$pshell" -NonInteractive -NoProfile $myInvocation.MyCommand'
65
65
}
66
66
$ExitResult = $LASTEXITCODE
67
67
If ($FSRedirection -eq $True ) {
@@ -71,7 +71,7 @@ public static extern bool Wow64RevertWow64FsRedirection(ref IntPtr ptr);
71
71
"@
72
72
$Kernel32Default = Add-Type - MemberDefinition $MethodSignature - Namespace " Kernel32" - Passthru - Name RevertWow64Redirection
73
73
[ref ]$defaultptr = New-Object System.IntPtr
74
- $Result = $Kernel32Default ::Wow64RevertWow64FsRedirection($defaultptr )
74
+ # $Result = $Kernel32Default::Wow64RevertWow64FsRedirection($defaultptr)
75
75
}
76
76
Write-Warning ' Exiting 64-bit session. Module will only remain loaded in native 64-bit PowerShell environment.'
77
77
Exit $ExitResult
0 commit comments