Advanced PowerShell - Runspaces

Поделиться
HTML-код
  • Опубликовано: 1 янв 2025

Комментарии • 12

  • @freshmaker4o
    @freshmaker4o 20 дней назад

    A lot of food for thought, thanks!

  • @JB-tq1ly
    @JB-tq1ly 2 года назад +1

    Thanks for sharing with us Adam! I do also appreciate Universal Dashboard !

  • @RAMChiTribe
    @RAMChiTribe 2 года назад +1

    I use your visual studio forms tool to create a form and I use the concepts in this video to control that form. I am making windows apps for selenium automation. Much respect.

  • @space_0027
    @space_0027 2 года назад +1

    This is really cool. Thanks for sharing!

  • @HumanNamedNick
    @HumanNamedNick 2 года назад

    Another cool little shortcut is if you do not specify a runspace for your powershell object, a new one is created for you:
    $PowerShell = [powershell]::Create()
    $PowerShell.AddScript("Get-ChildItem") # after running this, while the code isn't invoked, a new runspace is created.
    if you null out the variable or remove it, from what I can tell, it also disposes that runspace which is kind of neat.
    Runspaces can help you overcome some unique problems.

  • @charliesherman7533
    @charliesherman7533 8 месяцев назад

    Hi Adam, Thanks for this. Question. If I have 2 window forms running in their own runspaces. How can I close and dispose the 2nd window thru a button or an event in the 1st window?

  • @ThisGuyDakota
    @ThisGuyDakota 2 года назад

    Just wondering, why do the variables in the addscript method need a backtick? It feels like it should be escaping the dollar sign as a variable 🤔

    • @TheDJRiffin
      @TheDJRiffin 9 месяцев назад

      My first thought is that if you didn't have the back tick it would look for that variable in the current scope. But we only want the variable in that instance of the powershell object. Then we invoke it.
      If we just had the variable in the 'addscript' without the back tick and without the invoke, it may look for the variable, not find it and then not end up parsing the name of the variable into the powershell instance. (either by returning an error to the user, or parsing a null value, or parsing a value from our current scope instead of just the name of the variable.)

  • @kevinalbrecht
    @kevinalbrecht 2 года назад

    What version does invokeAsync start being supported?

    • @AdamDriscoll
      @AdamDriscoll  2 года назад +2

      Not 100% sure exactly what version but it's not available in WinPS 5.1. You'll need to use BeginInvoke instead: docs.microsoft.com/en-us/dotnet/api/system.management.automation.powershell.begininvoke?view=powershellsdk-1.1.0

    • @kevinalbrecht
      @kevinalbrecht 2 года назад

      @@AdamDriscoll Awesome, thanks for taking the time to reply Adam!