Run PowerShell in .NET

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ก.พ. 2025
  • In this video, I show how to create a .NET 6 console application that takes advantage of the PowerShell SDK to run scripts and commands. We also touch on error handling and inputs\outputs.
    The example code this video can be found here: github.com/ada...

ความคิดเห็น • 10

  • @MichaelButt-i4i
    @MichaelButt-i4i 11 หลายเดือนก่อน

    Hey, there. Thanks for the run down here, it was super useful. I do have one question though. How are you able to use Console.WriteLine and ReadLine without using System;?
    I am still having to use it for similar code. I am using Visual Studio 2019 and not VSCode, though I'm not sure if it's relevant.

  • @krzysztoff8813
    @krzysztoff8813 2 ปีที่แล้ว +1

    How do I lanuch my app with the administrator (elevated) rights? I am trying to 'Get-VM", but prompt just closes.

    • @ozb8337
      @ozb8337 9 หลายเดือนก่อน

      Did you ever figure this out @krzysztoff8813? I have the same issue now

  • @SilentNorn
    @SilentNorn 10 หลายเดือนก่อน

    typed dotnet add package Microsoft.PowerShell.SDK in Terminal. error: for the paket "Microsoft.PowerShell.SDK" are no versions available. I installed the PowerShell SDK beforehand and even restarted my pc. what am I doing wrong?

    • @SilentNorn
      @SilentNorn 10 หลายเดือนก่อน

      Apparently neither DotNetSDK 6 nor 8 support PowerShell anymore. I am going to stay with python, where it still works...

  • @anderson.martines
    @anderson.martines ปีที่แล้ว

    the bamespace Automation doesnt found in my project, even installing the

  • @anderson.martines
    @anderson.martines ปีที่แล้ว

    \o/, aparently the automation could be removed that version 7.4, but stays still 7.2

  • @AyanMullick
    @AyanMullick 2 ปีที่แล้ว

    How can one run `Write-Output 'Hello world'` on the browser? Adding the PowerShell SDK fails on REPL.it

    • @AdamDriscoll
      @AdamDriscoll  2 ปีที่แล้ว +2

      Not quite sure why Write-Host isn't working but I was able to add the SDK in my REPL.it. imgur.com/a/2ILU2em

    • @AyanMullick
      @AyanMullick 2 ปีที่แล้ว

      Yes, adding the SDK worked. However, 'Write-Host' fails, even on the shell. Thank you for the screenshot. How should one run it Blazor WASM? I couldn't load 'Microsoft.PowerShell.ConsoleHost'. i.imgur.com/mMEHq8k.png