Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

answered by (28 points)
0 votes

The simple answer is that PowerShell is object-oriented, and cmd.exe is string-based.  But that's glossing over the "why is this not just different, but BETTER?", which is the underlying question.

PSH can create .NET objects on the shell and allow the user to interact with them.  

I can, interactively, open an XML file, browse into it using DOM (ParentNode.ChildNode.ChildNode.Attribute), using XPath (SelectSingleNode("//host"), or [XML] class methods (GetParentNode()), edit it with $xml.CreateElement()/$node.AppendChild(), save it, and fire up in Visual Studio.  Interactively.

Normally, I would have to write a program to do it, compile it, run it, (wait for it to bomb out), and then manually open the file in VS.

I can write a script to fire up a new Internet Explorer, have it navigate to a URL, then start filling out fields in forms and expand dynamic content (with great difficulty)  using COM automation.  Or do the same thing in Excel - take a CSV file, dump it into Excel, reformat it (this table style, add these formulas, that column width) and save it.

I can resize the console window.  Or change the title.  Or increase the buffer (really?  Only 300 lines by default?)  Or copy the contents of the buffer, complete with colors.