Need help with nested multithreaded job

Hey guys,

I’m creating a test using a nested multithreaded job. I’m having trouble assuring that the value that I have in $message2 being made available in the nested job. I don’t have a problem with the script creating the text file in the directory that I specified, its just that the value turns up blank when I open the text file. By the way, I’ve also tried adding $using:message2 , but this just threw an error:

Start-RSJob : The value of the using variable ‘$using:message2’ cannot be retrieved because it has not been set in the local session.

$ParentFolder = “C:usersFamilyDesktopPII Searcher”

$Parentfolder | Start-RSJob -Name {“$($_)”} -Throttle 15 -ScriptBlock{

Param($targetfolder)

$message = “hello”

$global:message2 = “hello2”

$message | Out-File “$targetfoldermessage.txt”

$targetfolder | Start-RSJob -Name {“$($_)”} -Throttle 15 -ScriptBlock{

Param($targetfolder)

$message2 | Out-File “$targetfoldermessage2.txt”

}

}

submitted by /u/hou8182
[link] [comments]

Leave a Reply