File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,15 @@ process {
132132 }
133133 return ' [Tuple]::Create(' + ($Elements -join ' , ' ) + ' )' ;
134134 } elseif ($Type.IsSerializable -and -not $Type.IsPrimitive ) {
135- return " (ConvertFrom-CliXML -InputObject '$ ( ($Value | ConvertTo-CliXml - Depth 5 ) -replace " '" , " ''" ) ')" ;
135+ # For PowerShell versions without native inline ConvertTo-CliXml support,
136+ # export the argument to a temporary CLIXML file and import it at runtime.
137+ if ($PSVersionTable.PSVersion -lt [Version ]' 7.5' ) {
138+ $argFile = [System.IO.Path ]::Combine([System.IO.Path ]::GetTempPath(), (' arg_' + ([System.Guid ]::NewGuid().ToString()) + ' .clixml' ))
139+ $Value | ExportTo- CliXml - Path $argFile - Depth 5
140+ return " (Import-Clixml -Path '$argFile ')" ;
141+ } else {
142+ return " (ConvertFrom-CliXML -InputObject '$ ( ($Value | ConvertTo-CliXml - Depth 5 ) -replace " '" , " ''" ) ')" ;
143+ }
136144 }
137145
138146 return ConvertTo-Json - InputObject $Value ;
@@ -240,6 +248,10 @@ try {
240248 return $capturedErrors
241249 }
242250 } finally {
251+ # Always clean arguments
252+ $argPattern = [System.IO.Path ]::Combine([System.IO.Path ]::GetTempPath(), ' arg_*.clixml' )
253+ Get-ChildItem - Path $argPattern - File - ErrorAction SilentlyContinue | Remove-Item - Force - ErrorAction SilentlyContinue
254+
243255 if ($DebugPreference -ne ' Continue' ) {
244256 if (Test-Path $wrapperPath ) {
245257 Remove-Item - Path $wrapperPath - Force - ErrorAction SilentlyContinue - WhatIf:$False
You can’t perform that action at this time.
0 commit comments