TONYSO

Tonyso Credo: "Look for a pattern, and solve it for everything"

What is the Deal with PowerShell?

What is the Deal with PowerShell?

  • Comments 3
  • Likes

What's the deal with PowerShell?

Here is the VBScript code to list services:

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery("Select * from Win32_Service")

For Each objService in colServiceList

wscript.echo objService.name

Next

Here is the script to do the same thing in PowerShell: 

Get-Service

Which would you rather memorize?

Comments
  • A rather trivial example since sc query would do the same thing...

  • sc query works but the results of that are quite static. Also gsv is even shorter!

  • more importantly, the vbs script ejected a text stream, the powershell cmdlet actually returned an object, that happened to then be redendered to text for display purposes.  

    that's the real power, everything is an object.   :-)

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment