Page 1 of 1

More Interactive when writing Powershell Scripts

Posted: Thu Dec 13, 2007 5:37 am
by jdelatorre@hfinc.com
I'm not sure if this is already on the "Wish List", but would be EXTREMELY helpful if PrimalScript was more Interactive while scripting, similar to Powershell + code Editor/Powershell Anaylzer.For example when in PS+ code editor when typing a Grouped Expression:(get-date). the members for that expression would come up. Not sure what it would take to get this done but would be VERY nice.

More Interactive when writing Powershell Scripts

Posted: Fri Mar 21, 2008 8:20 am
by b0n3z
So it would basically do something like this?Get-Date | gm -m method

More Interactive when writing Powershell Scripts

Posted: Fri Mar 21, 2008 8:30 am
by joel.delatorre
yes except it would better resemble "get-date | gm" so you can see all the methods AND properties

get-date | gm -m method would only return avail methods

More Interactive when writing Powershell Scripts

Posted: Fri Mar 21, 2008 9:03 am
by b0n3z
Try using:get-date | gmThis should return back all the info. (GM is the alias to Get-Member). So in your previous request - I limited your request to just methods by doing the -membertype. You could also do the following to get just method & property:Get-Date | Get-Member -MemberType Method, PropertyYou can find more info in PowerShell about Get-Member by using:help gm -dHope this helps you out.b0n3z2008-03-21 16:05:01

More Interactive when writing Powershell Scripts

Posted: Fri Mar 21, 2008 9:21 am
by joel.delatorre
I think you missed the point. My request to Sapien is to add more interactivity to the IDE. that way you dont have to type in a console session "get-date | gm" to see the avail methods and properties. then go back to the IDE and type in wanted method/property. While IN the IDE typing the below expression or any grouped expression for that matter.
(get-date).

This would popup a intellisense menu that would show all available methods and properties for that given Grouped Expression. If you have PowerShell Plus installed try using the Editor and typing in the example im talking about to see what I mean.

More Interactive when writing Powershell Scripts

Posted: Sat Mar 22, 2008 1:08 am
by donj
The problem is that PrimalScript is a static environment. It can't execute each cmdlet to see what "comes back," and very few cmdlets actually return a fixed data type.

For example, if you run
(Gci)

What type would be displayed? A file? A folder? A registry key? An OU?

If you have Enterprise and have installed the .NET SDK, you can get code hinting and completion on types by statically typing them:

[date]$d = Get-Date

More Interactive when writing Powershell Scripts

Posted: Mon Mar 24, 2008 1:01 am
by joel.delatorre
So I guess there is no works in changing that.
To address what type would be returned would count on what Powershell returns. The only way to know for sure is Primalscript would have to execute the given expression in the background then capture that Type. But i also know that this presents a security risk so I understand why this hasnt been implemented.

More Interactive when writing Powershell Scripts

Posted: Mon Mar 24, 2008 1:18 am
by donj
Pretty much exactly. It could also be a production risk - if you put

(Remove-Item C:*.* -recurse)

You wouldn't be very happy if it ran :). The only other option would be for PrimalScript to maintain a static database, so that it could "know" what objects a command output - the problem with that, of course, is that we'd have to research EVERY command out there, not just those from Microsoft - we'd wind up being inconsistent and behind the times a lot, and nobody would thank us.

PowerShell v2 may be addressing this by providing more metadata with commands, so that an editor like PrimalScript could extract that metadata in advance and "know" more about the cmdlets. We'll see how that pans out as v2 shapes up.

More Interactive when writing Powershell Scripts

Posted: Mon Mar 24, 2008 1:26 am
by joel.delatorre
Good to know. Thanks for your quick response Don.