Skip to content

Commit cb4e02e

Browse files
v2.16.0
1 parent 5c09464 commit cb4e02e

10 files changed

Lines changed: 104 additions & 13 deletions

PSScriptTools.psd1

0 Bytes
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,4 +1147,4 @@ You will need to manually install the file.
11471147

11481148
Where possible these commands have been tested with PowerShell 7, but not every platform. If you encounter problems, have suggestions or other feedback, please post an issue. It is assumed you will not be running this commands on any edition of PowerShell Core or any beta releases of PowerShell 7.
11491149

1150-
Last Updated *2020-01-30 16:49:22Z UTC*
1150+
Last Updated *2020-02-12 19:38:27Z UTC*

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log for PSScriptTools
22

3+
## v2.16.0
4+
5+
+ Fixed bug in `New-CustomFileName` when using a 24 hour value. (Issue #62)
6+
+ Updated `Test-ExpressionForm` to clear the text results (Issue #61)
7+
+ Updated `Convertto-WPFGrid` to display a refresh message (Issue #43)
8+
+ Updated `foldersizeinfo.format.ps1xml` to include a KB formatted view
9+
310
## v2.15.1
411

512
+ Fixed bug in `Get-FolderSizeInfo` that was returning incorrect data (Issue #60)

docs/Test-ExpressionForm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Test-ExpressionForm [<CommonParameters>]
1919

2020
## DESCRIPTION
2121

22-
This command will display a WPF-based form that you can use to enter in testing information. Testing intervals are in seconds. All of the values are then passed to the Test-Expression command. Results will be displayed in the form.
22+
This command will display a WPF-based form that you can use to enter in testing information. Testing intervals are in seconds. All of the values are then passed to the Test-Expression command. Results will be displayed in the form. The results only show you how long the tests took, regardless of whether or not there were errors.
2323

2424
When you close the form, the last result object will be passed to the pipeline, including all metadata, the scriptblock and arguments.
2525

en-us/PSScriptTools-help.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11274,7 +11274,7 @@ OS : Microsoft Windows 8.1 Enterprise</dev:code>
1127411274
</maml:description>
1127511275
</command:details>
1127611276
<maml:description>
11277-
<maml:para>This command will display a WPF-based form that you can use to enter in testing information. Testing intervals are in seconds. All of the values are then passed to the Test-Expression command. Results will be displayed in the form.</maml:para>
11277+
<maml:para>This command will display a WPF-based form that you can use to enter in testing information. Testing intervals are in seconds. All of the values are then passed to the Test-Expression command. Results will be displayed in the form. The results only show you how long the tests took, regardless of whether or not there were errors.</maml:para>
1127811278
<maml:para>When you close the form, the last result object will be passed to the pipeline, including all metadata, the scriptblock and arguments.</maml:para>
1127911279
<maml:para>This command requires a Windows platform that supports WPF.</maml:para>
1128011280
</maml:description>

formats/foldersizeinfo.format.ps1xml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,59 @@ format type data generated 01/29/2020 13:25:45 by BOVINE320\Jeff
163163
</TableRowEntries>
164164
</TableControl>
165165
</View>
166+
<View>
167+
<!--Created 01/29/2020 13:25:45 by BOVINE320\Jeff-->
168+
<Name>KB</Name>
169+
<ViewSelectedBy>
170+
<TypeName>FolderSizeInfo</TypeName>
171+
</ViewSelectedBy>
172+
<TableControl>
173+
<TableHeaders>
174+
<TableColumnHeader>
175+
<Label>Computername</Label>
176+
<Width>15</Width>
177+
<Alignment>left</Alignment>
178+
</TableColumnHeader>
179+
<TableColumnHeader>
180+
<Label>Path</Label>
181+
<Width>48</Width>
182+
<Alignment>left</Alignment>
183+
</TableColumnHeader>
184+
<TableColumnHeader>
185+
<Label>TotalFiles</Label>
186+
<Width>13</Width>
187+
<Alignment>right</Alignment>
188+
</TableColumnHeader>
189+
<TableColumnHeader>
190+
<Label>TotalSizeKB</Label>
191+
<Width>13</Width>
192+
<Alignment>right</Alignment>
193+
</TableColumnHeader>
194+
</TableHeaders>
195+
<TableRowEntries>
196+
<TableRowEntry>
197+
<TableColumnItems>
198+
<!--
199+
By default the entries use property names, but you can replace them with scriptblocks.
200+
<ScriptBlock>$_.foo /1mb -as [int]</ScriptBlock>
201+
-->
202+
<TableColumnItem>
203+
<PropertyName>Computername</PropertyName>
204+
</TableColumnItem>
205+
<TableColumnItem>
206+
<PropertyName>Path</PropertyName>
207+
</TableColumnItem>
208+
<TableColumnItem>
209+
<PropertyName>TotalFiles</PropertyName>
210+
</TableColumnItem>
211+
<TableColumnItem>
212+
<ScriptBlock>[math]::round($_.totalSize /1kb,4)</ScriptBlock>
213+
</TableColumnItem>
214+
</TableColumnItems>
215+
</TableRowEntry>
216+
</TableRowEntries>
217+
</TableControl>
218+
</View>
219+
166220
</ViewDefinitions>
167221
</Configuration>

functions/ConvertTo-WPFGrid.ps1

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ Function ConvertTo-WPFGrid {
107107
Add-Type -AssemblyName PresentationFramework
108108
Add-Type -AssemblyName PresentationCore
109109

110+
Function _refresh {
111+
#this is a function to refresh a UI element
112+
Param($element)
113+
114+
$element.Dispatcher.invoke("render", [action] {})
115+
[System.Threading.Thread]::Sleep(50)
116+
117+
}
118+
110119
#get maximum available working area on the screen
111120
$s = [System.Windows.SystemParameters]::WorkArea
112121

@@ -150,7 +159,7 @@ Function ConvertTo-WPFGrid {
150159
#reserved for future use
151160
})
152161
#Create a grid to hold the datagrid
153-
$Grid = new-object System.Windows.Controls.Grid
162+
$Grid = New-Object System.Windows.Controls.Grid
154163

155164
$Grid.HorizontalAlignment = "stretch"
156165
$grid.VerticalAlignment = "stretch"
@@ -168,10 +177,11 @@ Function ConvertTo-WPFGrid {
168177
$btnRefresh.add_click( {
169178
[System.Windows.Input.Mouse]::OverrideCursor = [System.Windows.Input.Cursors]::Wait
170179

171-
$form.Title = "$Title ...refreshing content. Please wait."
180+
$status.Text = "...refreshing content. Please wait."
181+
_refresh $status
172182

173183
$timer.stop()
174-
start-sleep -seconds 3
184+
Start-Sleep -seconds 3
175185

176186
$datagrid.itemssource = Invoke-Command -ScriptBlock $cmd
177187

@@ -295,7 +305,7 @@ Function ConvertTo-WPFGrid {
295305
$script:count = $timeout
296306
$script:now = Get-Date
297307
[datetime]$script:terminate = $now.AddSeconds($timeout)
298-
$ts = new-timespan -Seconds $script:count
308+
$ts = New-TimeSpan -Seconds $script:count
299309
$status.text = " Last updated $script:Now - refresh in $($ts.tostring()) seconds"
300310
$Timer.Start()
301311
$form.title = $Title

functions/FileNameTools.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ You can create a template string using any of these variables, including the % s
107107
'%month' = "{0:MM}" -f $now
108108
'%dayofweek' = $now.DayOfWeek
109109
'%day' = "{0:dd}" -f $now
110-
'%hour' = "{0:hh}" -f $now
111110
'%hour24' = "{0:HH}" -f $now
111+
'%hour' = "{0:hh}" -f $now
112112
'%minute' = "{0:mm}" -f $now
113113
'%seconds' = "{0:ss}" -f $now
114114
'%time' = "{0}{1}{2}" -f $now.hour, $now.minute, $now.Second

functions/Test-Expression.ps1

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Function _TestMe {
4747
}
4848

4949
$TestResults = $TestData |
50-
Measure-Object -Property TotalMilliseconds -Average -Maximum -Minimum |
51-
Select-Object -Property @{Name = "Tests"; Expression = { $_.Count } },
50+
Measure-Object -Property TotalMilliseconds -Average -Maximum -Minimum |
51+
Select-Object -Property @{Name = "Tests"; Expression = { $_.Count } },
5252
@{Name = "TestInterval"; Expression = { $TestInterval } },
5353
@{Name = "AverageMS"; Expression = { $_.Average } },
5454
@{Name = "MinimumMS"; Expression = { $_.Minimum } },
@@ -198,6 +198,7 @@ Function Test-ExpressionForm {
198198
if ((Test-IsPSWindows)) {
199199

200200
Add-Type -AssemblyName PresentationFramework
201+
Add-Type -assemblyName PresentationCore
201202

202203
[xml]$xaml = Get-Content $psscriptroot\form.xaml
203204

@@ -237,11 +238,24 @@ Function Test-ExpressionForm {
237238

238239
$quit.add_click( { $form.close() })
239240

241+
Function _refresh {
242+
#this is a function to refresh a UI element
243+
Param($element)
244+
245+
$element.Dispatcher.invoke("render", [action]{})
246+
[System.Threading.Thread]::Sleep(50)
247+
248+
}
249+
240250
$run.add_click( {
241251

252+
$results.text = "Testing...please wait"
253+
_refresh $results
254+
242255
#uncomment for troubleshooting
243256
#write-host "running" -ForegroundColor green
244257

258+
$form.Dispatcher.invoke([action]{
245259
if ($sb.Text -notmatch "\w") {
246260
Write-Warning "You must enter something to test!"
247261
Return
@@ -272,10 +286,16 @@ Function Test-ExpressionForm {
272286
#uncomment for troubleshooting
273287
#$params | out-string | write-host -ForegroundColor cyan
274288

275-
$script:out = Test-Expression @params
276-
277-
$results.text = ($script:out | Select-Object -property * -exclude OS, Expression, Arguments | Out-String).Trim()
289+
$script:out = Test-Expression @params -errorvariable ev
290+
if ($script:out) {
291+
$data = ($script:out | Select-Object -property * -exclude OS, Expression, Arguments | Out-String).Trim()
292+
}
293+
else {
294+
$data = $ev.exception[0].message
295+
}
296+
$results.text = $data
278297
$form.Cursor = [System.Windows.Input.Cursors]::Default
298+
})
279299
})
280300

281301
[void]$sb.Focus()

functions/form.xaml

-4 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)