'Input gets changed inside a scriptblock
I have this script with a scriptblock:
$RoboArgs = @{
Source = '01'
Target = '02'
ExtraArgs = '/e', '/purge'
}
Write-Host @RoboArgs
Start-ThreadJob -InputObject $RoboArgs -ScriptBlock {
. robocopy_invoke.ps1
Write-Host @input
} | Receive-Job -Wait -AutoRemoveJob
I want to call a function defined in the robocopy_invoke.ps1 module using the input parameter (Invoke-Robocopy @RoboArgs), but the input parameter's contents somehow get changed once it enters the scriptblock.
Here's the output:
-Target: 02 -ExtraArgs: /e /purge -Source: 01
System.Management.Automation.Runspaces.PipelineReader`1+<GetReadEnumerator>d__20[System.Object]
Why is the output different for the two Write-Host calls?
How can I make the second one like the first one?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
