I know that Powershell is quite powerful in that it is a scripting language in which you have access to the entire .Net framework (thats all I know about it). But i'm struggling to understand what's the big hype about Powershell when I could use C# to code the exact same thing?
- It's not a compiled language.
- It has a plugin ecosystem with lots of 'libraries' for doing various domain specific things like copying files, playing with AD, Exchange.
- It's the right tool for a different, slightly overlapping set of jobs.
- It's a lot more powerful and consistent than CMD.EXE and other things evolved from command shells that needed to fit into 8K RAM.
And why are you using C# anyway, ILASM can do everything with much more control, and you're just calling stuff in the BCL anyway.
I think you are asking the wrong question. It should be: "Why should I use C# when I could use Powershell to code the same thing?"
This is the old argument of scripting versus compiled software revisited. A scripting solution is more flexible (you just need Notepad to edit the script, no compiler is required).
For a small task, a script is faster to write, deploy and change than creating a project in Visual Studio, compiling it, deploying it to the target, correcting the code, compiling it again, deploaing it again...
For any bigger task, I definitely prefer an IDE that compiles my code. The error messages on a broken build alone are a huge help for finding the cause. (Runtime efficiency is usually better in a compiled software, but with modern CPUs it comes down to a difference of a few milli seconds, so for most projects, it does not matter any more.)
You can do any kind of project in either C# or Powershell. That doesn't mean you should.
When not using Powershell as a shell but a programming environment, you can think of Powershell as a kind of interactive .NET playground. I'd never use Powershell for GUI prototyping but I have used it in the past for playing around with .NET objects and their methods to solve a particular problem. Simply altering a commandline is more productive than doing an edit/save/compile/run cycle every time you make a change.
Furthermore, the appropriate domains for either language are very different. Powershell is, at its heart an adminstration and automation tool, having streamlined access to many things that may be more awkward to use from another environment, like the Registry, certificate store, WMI and others.
You probably don't want to write an enterprisey database application with Powershell and you probably don't want to write a C# program just to copy some stuff around in the file system.
I generalized your question into the following:
Why would I use (higher level language that I know little about) over (lower level language I know more about)?
The point of a higher level language is to abstract common tasks so that they are faster to write. Many people who ask this question cannot conceive of this benefit of a higher level language because they are already comfortable with their lower level language.
In the end, it all comes down to your willingness to learn the abstractions of a higher level language in hopes that you can become as proficient in it as the lower one.