Skip to content

Commit 4188226

Browse files
Merge pull request #62 from PowershellFrameworkCollective/Development
2.2.35
2 parents b51db5e + 9fa0a88 commit 4188226

File tree

20 files changed

+417
-199
lines changed

20 files changed

+417
-199
lines changed

PSUtil/PSUtil.psd1

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
RootModule = 'PSUtil.psm1'
44

55
# Version number of this module.
6-
ModuleVersion = '2.1.28'
6+
7+
ModuleVersion = '2.2.35'
78

89
# ID used to uniquely identify this module
910
GUID = '9ef51588-c40c-4064-910d-9b624b758cf6'
@@ -26,8 +27,8 @@
2627
# Modules that must be imported into the global environment prior to importing
2728
# this module
2829
RequiredModules = @(
29-
@{ ModuleName = 'PSFramework'; ModuleVersion = '1.1.59' }
30-
@{ ModuleName = 'string'; ModuleVersion = '0.6.1' }
30+
@{ ModuleName = 'PSFramework'; ModuleVersion = '1.6.205' }
31+
@{ ModuleName = 'string'; ModuleVersion = '1.0.0' }
3132
)
3233

3334
# Assemblies that must be loaded prior to importing this module
@@ -44,6 +45,7 @@
4445
'Backup-PSULocation'
4546
'Convert-PSUObject'
4647
'Expand-PSUObject'
48+
'Get-PSUCalendarWeek'
4749
'Get-PSUPathAlias'
4850
'Invoke-PSUDesktop'
4951
'Invoke-PSUExplorer'
@@ -68,10 +70,10 @@
6870
)
6971

7072
# Cmdlets to export from this module
71-
CmdletsToExport = ''
73+
# CmdletsToExport = ''
7274

7375
# Variables to export from this module
74-
VariablesToExport = ''
76+
# VariablesToExport = ''
7577

7678
# Aliases to export from this module
7779
AliasesToExport = @(
@@ -82,8 +84,10 @@
8284
'c'
8385
'cast'
8486
'cfj'
87+
'cfx'
8588
'convert'
8689
'ctj'
90+
'ctx'
8791
'desktop'
8892
'ec'
8993
'ex'
@@ -115,6 +119,7 @@
115119
'split'
116120
'Split-PSUString'
117121
'spo'
122+
'teach'
118123
'temp'
119124
'timer'
120125
'trim'

PSUtil/bin/PSUtil.dll

0 Bytes
Binary file not shown.

PSUtil/bin/PSUtil.pdb

10 KB
Binary file not shown.

PSUtil/bin/PSUtil.xml

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PSUtil/changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
# Changelog
2+
3+
## 2.2.35 (2021-10-13)
4+
5+
- New: Object Conversion - NT <--> SID
6+
- New: Object Conversion - string <--> base64
7+
- New: Command Get-PSUCalendarWeek - Calculates the calendar week of the specified date.
8+
- Upd: Start-PSUTimer - added `-RandomInterval` parameter, randomizing the sound playback interval
9+
- Upd: Start-PSUTimer - added `-DisableScreensaver` parameter, blocking screensaver for the duration of the timer
10+
- Upd: Start-PSUTimer - now automatically adds a day if the destination-time is in the past
11+
- Upd: Manifest - added ctx and cfx to the aliases exported, enabling auto-import from using those.
12+
213
## 2.1.28 (2020-03-21)
314
- New: Component: Knowledge - store and search knowledge
415
- New: Command: Read-PSUKnowledge (read, page, learn) - retrieves stored knowledge

PSUtil/functions/knowledge/Write-PSUKnowledge.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,5 @@
104104
catch { Stop-PSFFunction -String 'Set-PSUKnowledge.Book.ExportFailed' -StringValues $Name, $Book, $bookPath -ErrorRecord $_ -EnableException $EnableException -Continue }
105105
}
106106
}
107-
}
107+
}
108+
Import-PSUAlias -Name 'teach' -Command Write-PSUKnowledge

PSUtil/functions/objects/Convert-PSUObject.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
Use this if you want the function to throw terminating errors you want to catch.
2626
2727
.EXAMPLE
28-
PS C:\> 100..110 | convert IntDec IntHex
28+
PS C:\> 100..110 | convert dec hex
2929
3030
Converts the numbers 100 through 110 from decimal to hexadecimal.
3131
#>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
function Get-PSUCalendarWeek {
2+
<#
3+
.SYNOPSIS
4+
Calculates the calendar week of the specified date.
5+
6+
.DESCRIPTION
7+
Calculates the calendar week of the specified date.
8+
Can be customized to fit the calendar rules of a given culture.
9+
10+
.PARAMETER Date
11+
The date for which to process the calendar week.
12+
Defaults to the current time and date.
13+
14+
.PARAMETER FirstDay
15+
Which day is considered the first day of the week.
16+
Defaults to the current or selected culture.
17+
18+
.PARAMETER WeekRule
19+
The rule by which the first week of the year is determined.
20+
Defaults to the current or selected culture.
21+
22+
.PARAMETER Culture
23+
The culture to use when determining the calendarweek of the specified date.
24+
Defaults to the current culture.
25+
26+
.EXAMPLE
27+
PS C:\> Get-PSUCalendarWeek
28+
29+
Gets the current calendar week
30+
#>
31+
[CmdletBinding()]
32+
param (
33+
[PSFDateTime]
34+
$Date = (Get-Date),
35+
36+
[DayOfWeek]
37+
$FirstDay,
38+
39+
[System.Globalization.CalendarWeekRule]
40+
$WeekRule,
41+
42+
[System.Globalization.CultureInfo]
43+
$Culture = (Get-Culture)
44+
)
45+
46+
process {
47+
$first = $FirstDay
48+
if (Test-PSFParameterBinding -ParameterName FirstDay -Not -BoundParameters $PSBoundParameters) {
49+
$first = $Culture.DateTimeFormat.FirstDayOfWeek
50+
}
51+
$wRule = $WeekRule
52+
if (Test-PSFParameterBinding -ParameterName WeekRule -Not -BoundParameters $PSBoundParameters) {
53+
$wRule = $Culture.DateTimeFormat.CalendarWeekRule
54+
}
55+
$Culture.Calendar.GetWeekOfYear($Date, $wRule, $first)
56+
}
57+
}

PSUtil/functions/other/Start-PSUTimer.ps1

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
.PARAMETER AlarmInterval
2525
In what time interval to write warnings and send sound.
2626
27+
.PARAMETER RandomInterval
28+
Randomizes the interval between two signal sounds.
29+
2730
.PARAMETER MinFrequency
2831
The minimum frequency of the beeps.
2932
Must be at least one lower than MaxFrequency.
@@ -34,11 +37,16 @@
3437
Must be at least one higher than MaxFrequency.
3538
Increase delta to play random frequency sounds on each beep.
3639
40+
.PARAMETER DisableScreensaver
41+
Disables the screensaver while the timer is pending.
42+
This only works on Windows and has the command pretend to be a video & backup application, preventing untimely activation of a screensaver.
43+
3744
.EXAMPLE
3845
PS C:\> timer 170 Tea
3946
4047
After 170 Duration give warning that the tea is ready.
4148
#>
49+
[Alias('timer')]
4250
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
4351
[CmdletBinding()]
4452
param (
@@ -60,17 +68,25 @@
6068
[int]
6169
$AlarmInterval = 250,
6270

71+
[switch]
72+
$RandomInterval,
73+
6374
[int]
6475
$MinFrequency = 2999,
6576

6677
[int]
67-
$MaxFrequency = 3000
78+
$MaxFrequency = 3000,
79+
80+
[switch]
81+
$DisableScreensaver
6882
)
6983

7084
begin
7185
{
7286
$start = Get-Date
7387
$end = $Duration.Value
88+
# Allow conveniently specifying absolute times for the day after
89+
if ($end -lt $start) { $end = $end.AddDays(1) }
7490

7591
function Get-FriendlyTime
7692
{
@@ -111,6 +127,7 @@
111127
while ($end -gt (Get-Date))
112128
{
113129
Start-Sleep -Milliseconds 500
130+
if ($DisableScreensaver) { [PSUtil.Utility.UtilityHost]::DisableScreensaver() }
114131

115132
if (-not $NoProgress)
116133
{
@@ -129,10 +146,11 @@
129146
while ($countAlarm -lt $AlarmCount)
130147
{
131148
Write-PSFHostColor -String "(<c='sub'>$countAlarm</c>) ### <c='em'>$($Message)</c> ###"
149+
if ($DisableScreensaver) { [PSUtil.Utility.UtilityHost]::DisableScreensaver() }
132150
[System.Console]::Beep((Get-Random -Minimum $MinFrequency -Maximum $MaxFrequency), $AlarmInterval)
133-
Start-Sleep -Milliseconds $AlarmInterval
151+
if ($RandomInterval) { Start-Sleep -Milliseconds (Get-Random -Minimum $AlarmInterval -Maximum ($AlarmInterval * 2)) }
152+
else { Start-Sleep -Milliseconds $AlarmInterval }
134153
$countAlarm++
135154
}
136155
}
137-
}
138-
Import-PSUAlias -Name "timer" -Command "Start-PSUTimer"
156+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Register-PSUObjectConversion -From NT -To SID -ScriptBlock {
2+
param ($InputObject)
3+
([System.Security.Principal.NTAccount]$InputObject).Translate([System.Security.Principal.SecurityIdentifier])
4+
}
5+
Register-PSUObjectConversion -From SID -To NT -ScriptBlock {
6+
param ($InputObject)
7+
([System.Security.Principal.SecurityIdentifier]$InputObject).Translate([System.Security.Principal.NTAccount])
8+
}

0 commit comments

Comments
 (0)