Author Posts

January 1, 2012 at 12:00 am

by nowa at 2012-09-25 06:44:48

Hi!

I'm kinda new to powershell scripting but try to learn as i go.
I have made a powershell script who counts all our SPLA licenses based on group memberships and saves the report as a .xml with date so we can bring them back up in gridview by running " import-clixml Filepath | out-gridview "

I am looking for a easy way to open the reports without having to type inn the file-path to the specific file each time I want to check an old report. Like a PS script with a dropdown list of the files in my Report folder so I can choose the file to open in gridview.

I have played around with this code for listing the files:
$Folder= "D:\Filer\SPLA"
$Files=Get-Childitem -Path $Folder

But cant find a good way to get them into a dropdown list and make it work as a path in: "import-clixml | out-gridview "

Anyone got a suggestion ?

PS: Please ask if you need more backgound info on what I'm trying to do 🙂

Regards,
Thomas Strand

by JeffH at 2012-09-25 06:50:27

Are you trying to create a GUI prompt or something from the command line?

by nowa at 2012-09-25 06:53:06

Yeah, something like that.

I tried to adapt what i found here: http://www.blkmtn.org/PowerShell-Window ... P_Launcher
but with no luck..

by JeffH at 2012-09-25 07:05:40

If you have PowerShell v3, then use Out-GridView as your gui:

dir *.xml | Select Name,@{Name="Path";Expression={$_.Fullname}} | out-gridview -PassThru | import-clixml

I'm adding a Path property so that when you select the file in Out-Gridview and press OK, the object is piped to Import-clixml.