Automation

 View Only
  • 1.  Jobs hanging when scriptblock needs to print output

    Posted Mar 29, 2019 02:34 PM

    Hello there,

    I've found many thread and forum that were subject to this bug (?), but I didn't find a solution that suits my environnement...

    I'm working on a Linux CentOS 7 with a PowerShell 6.1.1 package on it. I'm trying to make a loading print that show PowerCli commands is still running and is not crashed 'cause sometimes it's... Very... Very long...

    The issue is when I run the loading script the jobs never ends, the only one way to make them finish properly is to redirect output, if there are output directed to the console it hangs.

    However I want to keep the object that are returned from my jobs commands, I tried to Export-Clixml those outputs but the issue happens in this situation and I didn't find a way to export my objects in a xml file and avoid the issue by redirecting the output, if I do both export and redirect the xml file is empty.

    I've tried with simple commands passed to the -ScriptBlockString parameter, like Get-VM.

    This script is adapted from this one: http://www.vxav.fr/2017-08-08-easily-run-powercli-commands-as-jobs/

    Thanks !



  • 2.  RE: Jobs hanging when scriptblock needs to print output

    Posted Mar 29, 2019 08:02 PM

    It's not clear to me which bug you are referring to?

    When I run your script in PS v6 on a Windows box, everything seems to work ok.

    Did you encounter the same issue on other systems besides CentOS 7?



  • 3.  RE: Jobs hanging when scriptblock needs to print output

    Posted Apr 01, 2019 08:55 AM

    I can't use anything else than CentOS, it's a gateway builded to have specific access to our vCenter.

    There is some link I've found about this bug:

    https://communities.vmware.com/thread/461742

    This one were resolved by the post 5 and 7, the 5th is useable for me because of my environnement (CentOS), the 7th works and is similar to the next link: redirect output to a variable/file/nothing

    https://stackoverflow.com/questions/46524293/powercli-powershell-jobs-does-not-finish

    So the workaround is to use redirection to avoid jobs to hang. It works for me, but I want to use my object afterwards, so I tried to use Export-Clixml but either the jobs keeps hanging or the xml file is empty...



  • 4.  RE: Jobs hanging when scriptblock needs to print output

    Posted Apr 01, 2019 09:32 AM

    To make sure, did set the DisplayDepreciationWarnings option to $false with the Set-PowerCLIConfiguration cmdlet?

    You might try adding that as the 1st line in the script you launch with Start-Job.



  • 5.  RE: Jobs hanging when scriptblock needs to print output

    Posted Apr 01, 2019 01:31 PM

    It doesn't work even with the set command at the start of the job script block.

    Can't paste the Get-PowerCLIConfiguration command but the DisplayDeprecationWarnings are on false for all users.



  • 6.  RE: Jobs hanging when scriptblock needs to print output

    Posted Apr 01, 2019 01:40 PM

    You have to make sure the settings is false for the Session.
    If that still is true, the AllUsers will be overruled.



  • 7.  RE: Jobs hanging when scriptblock needs to print output

    Posted Apr 03, 2019 07:57 AM
    Hello, sorry for the delay, I've set this parameter to false for the session at the start of the job without more success..