Search code examples
c#.netpowershellbuildildasm

If Powershell is built on top of .Net, what is the reason to write scripts instead of C# code?


As a person who is new to Powershell I am not 100% clear at one point:

If

"In PowerShell, administrative tasks are generally performed by cmdlets (pronounced command-lets), specialized .NET classes implementing a particular operation."

What are the reasons to write scripts instead of writing .Net executables with those classes and compile them as console applications?


Solution

  • You could just as easily ask the question, what are the reasons to write applications in .NET when you can just as easily create fully fledged desktop and server software in PowerShell?

    There are reasons to use both in different circumstances. PoSH scripts themselves are simply small text files, and are very easy to write and maintain. As someone who dabbles in both, I'd say in a lot of circumstances system maintenance tasks are much easier to accomplish with a quickly whipped up PoSH script than with a .NET application.

    That said there are some things which are much easier to accomplish in .NET (I use C# myself), but the process of developing these is much more cumbersome, and requires an additional skillset not common among SysAdmins.

    Put simply, PoSH is targeted at SysAdmins and .NET is targeted at developers, but that's not to say there isn't some room for crossover.