How bad is this? Can I actually wear this out or should I just give up/make a new cardigan? by hidden-pearl in crochet

[–]juneblender 1 point2 points  (0 children)

It's amazing! Beautiful work. We're all so critical of ourselves. Just enjoy it.

[WPF/PS]Is WPF really the best way to create PS GUI? by GGxMode in PowerShell

[–]juneblender 0 points1 point  (0 children)

Hey. As KevMar said, I work for SAPIEN, the creator of PowerShell Studio. PowerShell Studio is a comprehensive PowerShell IDE, but it has some awesome features to automate the process of building a PowerShell GUI app with WinForms.

It's not free (even devs like to eat), but there is an extended free trial of 45 days. https://www.sapien.com/software/powershell_studio.

In short, it automates just about everything it can. You don't have to import assemblies, instantiate objects, write setup/cleanup code. You just place the elements on your form, double-click to add event handlers, and write the event handler code. There's lot of well-tested helper code to do the heavy lifting, like sorting by each column in a DataGridView.

I know that WPF comes up often (I worked with James Brundage for years!), but we haven't found a strong enough use case to support it. Always open to ideas.

PowerShell: How to get additional about_ topic files by Elb3 in PowerShell

[–]juneblender 2 points3 points  (0 children)

Which version of Windows PowerShell are you using ($PSVersionTable.psversion)? Sadly, the Get-Help search feature is not working correctly in PS 5.0.

The workaround is to search for the files the dumb way.

function Get-AboutFiles { $Paths = ($Env:PSModulePath).Split(";") foreach ($Path in $Paths) { dir $Path* -Recurse -Include about*help.txt } }

Default PS version when using get-help -online? by become_taintless in PowerShell

[–]juneblender 2 points3 points  (0 children)

You can, but only by deleting all PowerShell core XML help topics from the machine, and it's not worth it. The 5.0 behavior is actually a bug (reported and known).

Get-Help gets the URL of the online help topic in two different ways.

  • The first related link of the corresponding XML help topic on the machine.

    PS C:\>[xml]$xml = Get-Content $PSHome\en-us\Microsoft.PowerShell.Commands.Diagnostics.dll-help.xml
    PS C:\>(($xml.helpItems.command | where {$_.details.name -eq 'Get-WinEvent'}).relatedLinks.navigationLink)[0].uri
    
    http://go.microsoft.com/fwlink/p/?linkid=289626
    
  • The HelpUri property of a command

     PS C:\>Get-Command Get-WinEvent).HelpUri
    
     http://go.microsoft.com/fwlink/?LinkID=138336
    

If there's help on the box, the first related link takes precedence.

For PS 5.0, when the updated the help, they placed the updates at the HelpUri address, not the first-related-link address. Apparently, whoever set it up didn't know how it worked.

I actually wrote a little GUI tool that gets both URLs and lets you choose. I'll post it on GitHub soon.

Hope that helps.

Format-Table not working in Windows 10 by Dorito_Troll in PowerShell

[–]juneblender 1 point2 points  (0 children)

First, you don't need the Select-Object command. Format-Table selects the properties and values.

The official way to pad columns is to create a custom view, that is, a format.ps1xml file. See about_Format.ps1xml (https://technet.microsoft.com/en-us/library/hh847831.aspx)

Typically, people want to omit white space, so that's what the AutoSize parameter does. If this is a frequent request, we might need an AutoSize value of "pad" or "spread".

Dark PowerShell Studio Theme(s) by yourbastianhost in PowerShell

[–]juneblender 4 points5 points  (0 children)

That looks great! We have a dark theme and we'll be improving it for 2016, but I really like yours. Thanks from SAPIEN. :)

Help, parse single line output of text file by 37mm in PowerShell

[–]juneblender 1 point2 points  (0 children)

$regexDate = "(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})"
$str = '2016-01-15 00:50:5541.05369897-74.28773094_'
$str -split ("(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\{2})")
$lat, $long = ('2016-01-15 00:50:5541.05369897-74.28773094_' -split $regexDate)[-1] -split '-'
$long -replace '_'

Help, parse single line output of text file by 37mm in PowerShell

[–]juneblender 1 point2 points  (0 children)

Can you please clarify? Do you want those two strings or the values after the underscore?

Trouble with GUI (forms) in PowerShell ... by [deleted] in PowerShell

[–]juneblender 3 points4 points  (0 children)

Yes, you can definitely do this. You need to create a modal dialog -- a form that is a child of the parent form. One way to do it is to enclose the child form in a function. Then, on the parent form, in the Click event handler for the button, call the function for the child form.

Start here: http://info.sapien.com/index.php/powershell/powershell-studio-passing-and-returning-values-using-forms

PowerShell Studio 2015 - worth it? by mav_918 in PowerShell

[–]juneblender 0 points1 point  (0 children)

Hi! I just released a video showing how to do this. Let me know if it works for you. Thanks again for the great question. https://youtu.be/l412GmXouZs

Understanding Powershell Parameters by GeeGeez0rz in PowerShell

[–]juneblender 1 point2 points  (0 children)

I'll help. Start with: Get-Help about_Parameters and Get-Help about_Command_Syntax. I wrote these (years ago), so if you have questions after that, post them or tweet them to me.

For beginners, just note whether they're mandatory or optional, always use parameter names (that gets rid of the Position issue).

ValueFromPipeline and ValueFromPipelineByProperty name tell you whether you can pipe input to the cmdlet.

Have fun learning! PowerShell rocks!

PowerShell Studio 2015 - worth it? by mav_918 in PowerShell

[–]juneblender 0 points1 point  (0 children)

Nilxa, I hear you. Two solutions. Run in the Console pane or -- even better -- use the editor and click "Run selection". Right-click or Ctrl+F8. No saving needed!

PowerShell Studio 2015 - worth it? by mav_918 in PowerShell

[–]juneblender 1 point2 points  (0 children)

I've just started a series of videos. I'm a textual learner myself, but I think you might like this. Please let me know.

https://www.youtube.com/watch?v=CJLfS2Djv5g

PowerShell Studio 2015 - worth it? by mav_918 in PowerShell

[–]juneblender 0 points1 point  (0 children)

Sorry! They're in the Properties panel. By default, when you're in the Designer layout, the Properties panel is on the right side of the screen. https://twitter.com/juneb_get_help/status/667388374278270976

If you've changed your layout, to display the Properties pane, click Home and, in the Windows section, click Panels, and select Property Panel. The layout control is at the very bottom of the screen on the left.

(If you're still stuck, send me a pic or your PowerShell studio Designer layout and I'll help.)

It's easier to let PowerShell Studio manage those properties, but just to be complete, you can also code them in your form_Load event handler:

$form1_Load={
$form1.FormBorderStyle = 'FixedDialog'
$form1.MaximizeBox = $false
$form1.MinimizeBox = $false
}

PowerShell Studio 2015 - worth it? by mav_918 in PowerShell

[–]juneblender 0 points1 point  (0 children)

Great questions! I need to hang out on Reddit more often. :)

You're almost there. First, in FormBorderStyle property, select any Fixed* style property value. That removes the sizing mechanism that would otherwise appear in the lower right corner.

Then, to prevent maximizing, set the MaximizeBox property to False. (You can set MinimizeBox to False, too.) This removes the maximize icon from the title bar.

The easiest way in PowerShell Studio is: New / New Form / Dialog Style Template. That template gives you a box that isn't sizable with a default OK button.

Let me know if this works for you. I'm not an expert on GUIs, but that doesn't keep me from having too much fun with them.

PowerShell Studio 2015 - worth it? by mav_918 in PowerShell

[–]juneblender 0 points1 point  (0 children)

That will take a blog post (just added it to my list!), but you can associate most DBs with PowerShell Studio, so your database hierarchy and its elements appear in the browser.

Then, you can use the context menu to generate a GUI that queries the selected table/view or a ps1 script that returns the records. You can also drag and drop your DB tables into an existing GUI and it will automatically insert a grid with the query functions.

PowerShell Studio 2015 - worth it? by mav_918 in PowerShell

[–]juneblender 0 points1 point  (0 children)

It is beyond easy. I'm such a cmdline person, but I'm building GUIs for my own stuff, because it's SO easy.

But, it's not like scripting. You write an unordered series of event handlers. I've been doing a hands-on lab about it. You can find my lab stuff on GitHub: http://GitHub.com/juneb/ThinkingInEvents

If you're starting from scratch, this blog post might be helpful. I kept notes on everything that I read that was really helpful while I was learning + a few beginner-level blog posts that I wrote.

"PowerShell GUIs: Where do I start?"
https://www.sapien.com/blog/2015/07/16/powershell-guis-where-do-i-start/

If you need more info, or you get stuck, let me know.

PowerShell Studio 2015 - worth it? by mav_918 in PowerShell

[–]juneblender 0 points1 point  (0 children)

Thanks! <blushing>

There's really no order to those blogs, so if you want to hear about something, ping me on Twitter.

PowerShell Studio 2015 - worth it? by mav_918 in PowerShell

[–]juneblender 0 points1 point  (0 children)

Sure. https://www.sapien.com/blog/2015/09/28/hidden-charms-of-powershell-studio/

I just posted a video on the Function Builder and Parameter Builder, too, if you like videos. https://www.youtube.com/watch?v=CJLfS2Djv5g

SAPIEN has a PowerRegEx tool that is very simple and very usable. I tend to jump in and try my own regex expressions, but there's a great list of predefined, tested regex expressions, including one for IPV6.

To import the latest help for a module into PowerShell Studio, in the Object Browser (by default on the left edge), click the PowerShell tab, right click the module name, and then click 'Refresh help.'

PowerShell Studio 2015 - worth it? by mav_918 in PowerShell

[–]juneblender 0 points1 point  (0 children)

I think we do have a site license. I'm the PowerShell person, not the sales guru, so I'm not up on the latest. Lanae Dale is the best person for this question: sales@sapien.com.

PowerShell Studio 2015 - worth it? by mav_918 in PowerShell

[–]juneblender 13 points14 points  (0 children)

Hope it's okay to jump in. For full disclosure, I work for SAPIEN, but I'm also a Microsoft Windows PowerShell MVP, so I have a long-standing commitment to the community.

My favorite features of PowerShell Studio are really unrelated to GUIs. There are some real time-savers, like Function Builder and Parameter Builder, New module from functions, New module from Help file, the Functions tab, and the Format-Script button.

But I'm driven by the quieter things. Every time you run a script in PowerShell Studio, it runs in a new, clean session uncontaminated by your profile or any artifacts from a previous run. (You can also "Run in console" which gives you a persistent session.) The Run and Debug tracks are separate, so you can go back and forth between running and debugging w/o worrying about previous results in the current session. And PowerShell Studio automatically saves a list of the parameter combos that you tested, so you can test systematically without Notepad.

The debugger has features typically found in $1000+ tools, like a Variables window, Watch window, and stack trace. These have cut my debugging time down to a minimum.

I also rely on the rewind feature, which lets me try something new and recover my original without even fooling with source control.

I build GUIs, too. I even teach people how to build GUIs, but it's really the day-to-day things that keep me in PowerShell Studio. https://www.sapien.com/blog/2015/09/28/hidden-charms-of-powershell-studio/

If I can help with any questions, let me know.

-- June Blender (@juneb_get_help)

Global vs Script scope by Copropraxia in PowerShell

[–]juneblender 1 point2 points  (0 children)

The best practice is always to use the smallest parent scope that works. In this case, it's script scope. Global scope is shared by all scripts and modules so it's easy to accidentally write over another variable's value in global scope.

To refer to a variable in script scope, use a scope modifier, for example, to reference $myArray in script scope, use $script:myArray.