Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Invoke-Command fail during after many iterations

$
0
0

Hi,

I'm running few Invoke-Commands concurrent (for time efficiency) and sometimes after many iterations (10,000 - 100,000) the return command is a falls one. another attempt will cause this error:

[10.7.23.27] Processing data from remote server 10.7.23.27 failed with the following error message: Access is denied. For
more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (10.7.23.27:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : AccessDenied,PSSessionStateBroken

why is that happening after so many iterations? is there a affective way to do it at least as fast as this method and yet make it be more stable??

the code looks like this:

        $commands = StringToScriptBlock("...")
        $test = Invoke-Command -JobName name_a -ComputerName $target_ip -scriptBlock $commands

        $commands = StringToScriptBlock("....")
        $test = Invoke-Command -JobName name_b -ComputerName $target_ip -scriptBlock $commands

        $commands = StringToScriptBlock(".....") #.tgu.Physical.PCIConfigurationHeader.LinkStatus.negotiated_link_width  
        $test = Invoke-Command -JobName name_c -ComputerName $target_ip -scriptBlock $commands
        ...
        $rc = wait-job -name name_a -timeout 5
        $rc = wait-job -name name_b-timeout 5
        $rc = wait-job -name name_c -timeout 5
        ...
        $name_a = "0x" + '{0:x}' -f [int](Receive-Job -Name name_a)
        $name_b= "0x" + '{0:x}' -f [int](Receive-Job -Name name_b)
        $name_c = "0x" + '{0:x}' -f [int](Receive-Job -Name name_c)
        ...

        remove-job -Name name_a -force
        remove-job -Namename_b -force
        remove-job -Name name_c -force
       Start-Sleep -m 200


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>