More Interactive when writing Powershell Scripts

Post feature requests, product enhancement ideas, and other product-specific suggestions here. Do not post bug reports.
Forum rules
Do not post any licensing information in this forum.
Locked
User avatar
jdelatorre@hfinc.com
Posts: 54
Joined: Mon Sep 10, 2007 2:26 am

More Interactive when writing Powershell Scripts

Post by jdelatorre@hfinc.com » Thu Dec 13, 2007 6:37 am

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.

User avatar
b0n3z
Posts: 10
Joined: Fri Mar 21, 2008 9:39 am

More Interactive when writing Powershell Scripts

Post by b0n3z » Fri Mar 21, 2008 8:20 am

So it would basically do something like this?Get-Date | gm -m method

User avatar
joel.delatorre
Posts: 83
Joined: Tue Dec 16, 2008 5:51 am

More Interactive when writing Powershell Scripts

Post by joel.delatorre » Fri Mar 21, 2008 8:30 am

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

User avatar
b0n3z
Posts: 10
Joined: Fri Mar 21, 2008 9:39 am

More Interactive when writing Powershell Scripts

Post by b0n3z » Fri Mar 21, 2008 9:03 am

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

User avatar
joel.delatorre
Posts: 83
Joined: Tue Dec 16, 2008 5:51 am

More Interactive when writing Powershell Scripts

Post by joel.delatorre » Fri Mar 21, 2008 9:21 am

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.

User avatar
donj
Posts: 416
Joined: Thu Nov 16, 2006 9:02 pm

More Interactive when writing Powershell Scripts

Post by donj » Sat Mar 22, 2008 1:08 am

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

User avatar
joel.delatorre
Posts: 83
Joined: Tue Dec 16, 2008 5:51 am

More Interactive when writing Powershell Scripts

Post by joel.delatorre » Mon Mar 24, 2008 1:01 am

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.

User avatar
donj
Posts: 416
Joined: Thu Nov 16, 2006 9:02 pm

More Interactive when writing Powershell Scripts

Post by donj » Mon Mar 24, 2008 1:18 am

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.

User avatar
joel.delatorre
Posts: 83
Joined: Tue Dec 16, 2008 5:51 am

More Interactive when writing Powershell Scripts

Post by joel.delatorre » Mon Mar 24, 2008 1:26 am

Good to know. Thanks for your quick response Don.

Locked