Author Topic: PowerShell  (Read 2000 times)

0 Members and 1 Guest are viewing this topic.

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
PowerShell
« on: April 29, 2014, 12:52:11 AM »
I know  there is the new Python support which I am going to look into.
Just curious is there any plans for PowerShell support?

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: PowerShell
« Reply #1 on: April 29, 2014, 08:33:34 AM »
Python support is not exactly new, but I guess it depends on your definition of new.  :D

PowerShell support might be interesting.  How would you use it if it were available?

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: PowerShell
« Reply #2 on: April 29, 2014, 11:11:39 AM »
Well perhaps new to me would be more appropriate. :)

I have a XML struggling with and thought perhaps Python would be strangely easier importing XML than trying to RegEx it to pieces.
I was reviewing the Python documentation and seemed very neat, just thought since VC is windows only and thought native PowerShell support to do similar things would be interesting and perhaps lower learning curve for windows users that would presumably be more familiar with PowerShell vs Python....but I know you develop/supporting both could be a pain.

I saw python could expose some of the VC objects and such and know Posh leverages .net framework as well so just curious if this was possible or any plans.
I haven't really encountered the need to investigate the Python stuff until now since I've been working on some custom stuff but generically much of the things the python documentation suggests XML parsing, payload creation, math operations, more complicated logical operations/loops than LCB provides......etc.
Honestly right now I would imagine my thoughts would be mostly the same types of things I would try in Python I would try in Powershell.
I'm sure they have each have unique benefits / limitations from each other but I'm not explicitly aware of them. Just curious if viable alternative for some users since PowerShell is integral in the newer versions of Windows. Slightly more practical for some (me) to learn PowerShell more vs Python as well :)
When I was reading the wiki on Python, PoSh just popped into my head when I was looking at the examples.

« Last Edit: April 29, 2014, 11:53:56 AM by vulcanjedi »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: PowerShell
« Reply #3 on: April 29, 2014, 11:27:42 AM »
I think of PowerShell as a command line tool, and I'm not at all familiar with it as a programming tool.  I figured you could probably do anything in a PowerShell script now simply by using our launch actions.

Python is one of the easiest and most popular programming languages out there, and it is plenty powerful, and well integrated with VC, so unless there is some compelling reason to add PowerShell I think we will just stick with Python.  I doubt there are many VC users that are familiar with PowerShell as a programming language.

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: PowerShell
« Reply #4 on: April 30, 2014, 11:51:07 AM »
I'm still researching python and elementtree and lxml to try to parse my XML, but still having regex like fun :).
Any good suggestions/tutorials/examples for a parser I will welcome.

One pro for Powershell is the native xml parsing.

This 1 single line gets XML parsed into PoSh -very- nicely.
[xml]$sessions = get-content c:\folder\sessions.xml

« Last Edit: April 30, 2014, 12:24:21 PM by vulcanjedi »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: PowerShell
« Reply #5 on: April 30, 2014, 12:22:36 PM »
unzip the attached into the folder:

VC\plugins\PY\Lib\elementtree

then open the python plugin and paste the following code for a basic test:
Code: [Select]
import xml.etree.ElementTree as et

root = et.Element('Iamtheroot')
child = et.Element('iamthechild')
root.append(child)
child.attrib['name'] = "Charlie"
file = open("testelementtree.xml", 'w')
et.ElementTree(root).write(file)
file.close()


tree = et.parse('testelementtree.xml')
root = tree.getroot()
print root.tag