How To Use PowerShell in C#

preview_player
Показать описание
A short guide on how you can quickly get started using PowerShell in C# and capture the output. If you just want to see the code, check out the project on GitHub below

Рекомендации по теме
Комментарии
Автор

Great vid! Short and sweet, and to the point. Thanks a lot!

the_crazyguy
Автор

Thanks so much for the tutorial! I was stuck for a while with no output on the console, but after looking at your code I realized I forgot the "!" in the last if statement which caused my console to output nothing.

barnes
Автор

doesnt seem to work. always get: "system management automation namespace not found"

spiffylich
Автор

Nice short and sweet. Can this easily be converted to work in a winform?

stevea
Автор

In case I want to use my program on another computer, does it need to have powershell 7 installed for it to work? Does it need the DLL files to be present in a new environment, or can it be standalone?

Thank you for the answer in advance.

nyshone
Автор

this is very useful thank you very much

MrSurfsAlot
Автор

Hey man. This works great :) However, I was wondering if you know how I can have it display the full errors (or where to check them). I'm getting "An error has occured which PowerShell cannot handle..." for one of my scripts that I'm running from my app but I am having a hard time troubleshooting it with the generic error. Any help would be much appreciated thank you!

Saberune
Автор

Hey mate! Great video! not sure if you're still looking at this! I was wondering if you knew how to set the execution policy for the powershell instance? I tried:

_ps.AddCommand("Set-ExecutionPolicy").AddParameter("ExecutionPolicy", "Unrestricted").AddParameter("scope", "LocalMachine").Invoke();

But am receiving "AuthorizationManager check failed." as an error still :( I'm also running the C# program as an Administrator

@Blue Hippo

jamesmartin-kkuk