Skip to content

Commit 33ccdcc

Browse files
committed
Release 1.136.2025
1 parent 5db62ff commit 33ccdcc

26 files changed

Lines changed: 580 additions & 631 deletions

Functions/GenXdev.FileSystem/AssurePester.ps1

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,45 @@ function AssurePester {
2121
begin {
2222

2323
# inform user that we're checking pester installation
24-
Write-Verbose "Checking for Pester module installation..."
24+
Microsoft.PowerShell.Utility\Write-Verbose "Checking for Pester module installation..."
2525
}
2626

2727
process {
2828

2929
# attempt silent import of pester to check if it's available
30-
Import-Module -Name Pester -ErrorAction SilentlyContinue
30+
Microsoft.PowerShell.Core\Import-Module -Name Pester -ErrorAction SilentlyContinue
31+
32+
$found = (Microsoft.PowerShell.Core\Get-Module -Name Pester -ErrorAction SilentlyContinue);
3133

3234
# verify if pester module is now loaded in the current session
33-
if (-not (Get-Module -Name Pester -ErrorAction SilentlyContinue)) {
35+
if ((-not $found) -or ($found.Version -lt '5.7.0')) {
3436

3537
# notify about installation attempt through verbose and regular output
36-
Write-Verbose "Pester module not found, attempting installation..."
37-
Write-Host "Pester not found. Installing Pester..."
38+
Microsoft.PowerShell.Utility\Write-Verbose "Pester module not found, attempting installation..."
39+
Microsoft.PowerShell.Utility\Write-Host "Pester not found. Installing Pester..."
3840

3941
try {
4042
# install pester module from the powershell gallery
41-
$null = Install-Module -Name Pester `
43+
$null = PowerShellGet\Install-Module -Name Pester `
4244
-Force `
4345
-SkipPublisherCheck
4446

4547
# load the newly installed pester module
46-
$null = Import-Module -Name Pester -Force
48+
$null = Microsoft.PowerShell.Core\Import-Module -Name Pester -Force
4749

4850
# confirm successful installation
49-
Write-Host "Pester installed successfully."
50-
Write-Verbose "Pester module installation and import completed."
51+
Microsoft.PowerShell.Utility\Write-Host "Pester installed successfully."
52+
Microsoft.PowerShell.Utility\Write-Verbose "Pester module installation and import completed."
5153
}
5254
catch {
5355
# report any installation failures
54-
Write-Error "Failed to install Pester. Error: $PSItem"
55-
Write-Verbose "Pester installation failed with error."
56+
Microsoft.PowerShell.Utility\Write-Error "Failed to install Pester. Error: $PSItem"
57+
Microsoft.PowerShell.Utility\Write-Verbose "Pester installation failed with error."
5658
}
5759
}
5860
else {
5961
# inform that pester is already available
60-
Write-Verbose "Pester module already installed and imported."
62+
Microsoft.PowerShell.Utility\Write-Verbose "Pester module already installed and imported."
6163
}
6264
}
6365

Functions/GenXdev.FileSystem/Expand-Path.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function Expand-Path {
131131
}
132132
else {
133133

134-
$normalizedPath = Join-Path (Convert-Path ~) `
134+
$normalizedPath = Microsoft.PowerShell.Management\Join-Path (Microsoft.PowerShell.Management\Convert-Path ~) `
135135
$normalizedPath.Substring(1)
136136
}
137137
}
@@ -148,13 +148,13 @@ function Expand-Path {
148148

149149
if (($normalizedPath.Length -lt 3) -or ($normalizedPath.Substring(2, 1) -ne [System.IO.Path]::DirectorySeparatorChar)) {
150150

151-
Push-Location $normalizedPath.Substring(0, 2)
151+
Microsoft.PowerShell.Management\Push-Location $normalizedPath.Substring(0, 2)
152152
try {
153-
$normalizedPath = "$(Get-Location)$([IO.Path]::DirectorySeparatorChar)$($normalizedPath.Substring(2))"
153+
$normalizedPath = "$(Microsoft.PowerShell.Management\Get-Location)$([IO.Path]::DirectorySeparatorChar)$($normalizedPath.Substring(2))"
154154
$normalizedPath = [System.IO.Path]::GetFullPath($normalizedPath)
155155
}
156156
finally {
157-
Pop-Location
157+
Microsoft.PowerShell.Management\Pop-Location
158158
}
159159
}
160160
}
@@ -167,7 +167,7 @@ function Expand-Path {
167167
$normalizedPath = [System.IO.Path]::GetFullPath($normalizedPath)
168168
}
169169
catch {
170-
Write-Verbose "Failed to normalize path, keeping original"
170+
Microsoft.PowerShell.Utility\Write-Verbose "Failed to normalize path, keeping original"
171171
}
172172
}
173173
else {
@@ -211,7 +211,7 @@ function Expand-Path {
211211
[System.IO.Path]::Combine($pwd, $normalizedPath))
212212
}
213213
catch {
214-
$normalizedPath = Convert-Path $normalizedPath
214+
$normalizedPath = Microsoft.PowerShell.Management\Convert-Path $normalizedPath
215215
}
216216
}
217217

@@ -254,7 +254,7 @@ function Expand-Path {
254254
# create directory if it doesn't exist
255255
if (-not [IO.Directory]::Exists($directoryPath)) {
256256
$null = [IO.Directory]::CreateDirectory($directoryPath)
257-
Write-Verbose "Created directory: $directoryPath"
257+
Microsoft.PowerShell.Utility\Write-Verbose "Created directory: $directoryPath"
258258
}
259259
}
260260

@@ -266,12 +266,12 @@ function Expand-Path {
266266
throw "Cannot create file: Path refers to an existing directory"
267267
}
268268

269-
if (-not (Remove-ItemWithFallback -Path $normalizedPath)) {
269+
if (-not (GenXdev.FileSystem\Remove-ItemWithFallback -Path $normalizedPath)) {
270270

271271
throw "Failed to delete existing file: $normalizedPath"
272272
}
273273

274-
Write-Verbose "Deleted existing file: $normalizedPath"
274+
Microsoft.PowerShell.Utility\Write-Verbose "Deleted existing file: $normalizedPath"
275275
}
276276

277277
# handle file creation if requested
@@ -286,7 +286,7 @@ function Expand-Path {
286286
# create empty file if it doesn't exist
287287
if (-not [IO.File]::Exists($normalizedPath)) {
288288
$null = [IO.File]::WriteAllText($normalizedPath, "")
289-
Write-Verbose "Created empty file: $normalizedPath"
289+
Microsoft.PowerShell.Utility\Write-Verbose "Created empty file: $normalizedPath"
290290
}
291291
}
292292

Functions/GenXdev.FileSystem/Find-DuplicateFiles.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function Find-DuplicateFiles {
6262
begin {
6363
# convert all input paths to full filesystem paths
6464
$normalizedPaths = @()
65-
$Paths | ForEach-Object {
65+
$Paths | Microsoft.PowerShell.Core\ForEach-Object {
6666
$normalizedPaths += (GenXdev.FileSystem\Expand-Path $_)
6767
}
6868

@@ -96,17 +96,17 @@ function Find-DuplicateFiles {
9696
# verify directory exists before attempting to process
9797
if ([System.IO.Directory]::Exists($path)) {
9898

99-
Write-Verbose "Scanning directory for duplicates: $path"
99+
Microsoft.PowerShell.Utility\Write-Verbose "Scanning directory for duplicates: $path"
100100

101101
# use direct .NET IO for faster recursive file enumeration
102102
[System.IO.Directory]::GetFiles($path, "*.*",
103103
[System.IO.SearchOption]::AllDirectories) |
104-
ForEach-Object {
104+
Microsoft.PowerShell.Core\ForEach-Object {
105105
$null = $allFiles.Add([System.IO.FileInfo]::new($_))
106106
}
107107
}
108108
else {
109-
Write-Warning "Skipping non-existent directory: $path"
109+
Microsoft.PowerShell.Utility\Write-Warning "Skipping non-existent directory: $path"
110110
}
111111
}
112112
}
@@ -115,9 +115,9 @@ function Find-DuplicateFiles {
115115

116116
# group files by composite key and return only groups with duplicates
117117
$allFiles |
118-
Group-Object -Property { Get-FileKey $_ } |
119-
Where-Object { $_.Count -gt 1 } |
120-
ForEach-Object {
118+
Microsoft.PowerShell.Utility\Group-Object -Property { Get-FileKey $_ } |
119+
Microsoft.PowerShell.Core\Where-Object { $_.Count -gt 1 } |
120+
Microsoft.PowerShell.Core\ForEach-Object {
121121
# create result object for each duplicate group
122122
[PSCustomObject]@{
123123
FileName = $_.Group[0].Name

Functions/GenXdev.FileSystem/Find-Item.ps1

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,16 @@ function Find-Item {
164164

165165
process {
166166

167-
Write-Verbose ("Starting search with patterns: " +
167+
Microsoft.PowerShell.Utility\Write-Verbose ("Starting search with patterns: " +
168168
($SearchMask -join ", "))
169169

170170
# parallel search across all filesystem drives
171171
($AllDrives ? (
172-
Get-PSDrive -ErrorAction SilentlyContinue |
173-
Where-Object {
172+
Microsoft.PowerShell.Management\Get-PSDrive -ErrorAction SilentlyContinue |
173+
Microsoft.PowerShell.Core\Where-Object {
174174
($PSItem.Provider -Like "*FileSystem") -and ($PSItem.Name.Length -eq 1)
175175
}) : $null) |
176-
ForEach-Object -ThrottleLimit 8 -Parallel {
176+
Microsoft.PowerShell.Core\ForEach-Object -ThrottleLimit 8 -Parallel {
177177

178178
# helper function to search file contents using regex
179179
function Search-FileContent {
@@ -182,7 +182,7 @@ function Find-Item {
182182
[string] $using:Pattern
183183
)
184184

185-
return (Select-String -Path $filePath -Pattern $using:Pattern)
185+
return (Microsoft.PowerShell.Utility\Select-String -Path $filePath -Pattern $using:Pattern)
186186
}
187187

188188
# helper function to recursively search directories
@@ -439,7 +439,7 @@ function Find-Item {
439439
$invocationArgs.Directory = $true
440440

441441
# invoke the next directory scan
442-
Get-ChildItem @invocationArgs | ForEach-Object {
442+
Microsoft.PowerShell.Management\Get-ChildItem @invocationArgs | Microsoft.PowerShell.Core\ForEach-Object {
443443

444444
# are we following a /**/ pattern?
445445

@@ -466,7 +466,7 @@ function Find-Item {
466466
}
467467
)
468468

469-
Write-Verbose "Ending /**/ search for $nameToMatch in $($directories.Peek().currentPath)"
469+
Microsoft.PowerShell.Utility\Write-Verbose "Ending /**/ search for $nameToMatch in $($directories.Peek().currentPath)"
470470
}
471471
else {
472472
# schedule directory scan that will keep following the /**/ pattern
@@ -481,7 +481,7 @@ function Find-Item {
481481
}
482482
)
483483

484-
Write-Verbose "Continuing following /**/ search for $($directories.Peek().$nameToMatch) in $($directories.Peek().currentPath)"
484+
Microsoft.PowerShell.Utility\Write-Verbose "Continuing following /**/ search for $($directories.Peek().$nameToMatch) in $($directories.Peek().currentPath)"
485485
}
486486
}
487487

@@ -501,7 +501,7 @@ function Find-Item {
501501
}
502502
)
503503

504-
Write-Verbose "Starting /**/ search for $($directories.Peek().$nameToMatch) in $($directories.Peek().currentPath)"
504+
Microsoft.PowerShell.Utility\Write-Verbose "Starting /**/ search for $($directories.Peek().$nameToMatch) in $($directories.Peek().currentPath)"
505505
}
506506

507507
# we are not starting or following a /**/ pattern,
@@ -515,7 +515,7 @@ function Find-Item {
515515
currentDepth = $folder.currentDepth + 1
516516
}
517517
)
518-
Write-Verbose "Matched next directory for $($nameToMatch) in $($directories.Peek().currentPath)"
518+
Microsoft.PowerShell.Utility\Write-Verbose "Matched next directory for $($nameToMatch) in $($directories.Peek().currentPath)"
519519
}
520520
}
521521
continue;
@@ -524,7 +524,7 @@ function Find-Item {
524524
# we now at the last directory of the SearchPhrase supplied
525525
# invoke the directory scan
526526
# we scan for files and directories, since this is the last directory to match
527-
Get-ChildItem @invocationArgs | ForEach-Object {
527+
Microsoft.PowerShell.Management\Get-ChildItem @invocationArgs | Microsoft.PowerShell.Core\ForEach-Object {
528528

529529
# determine if the found item is a directory
530530
$isDirectory = $_ -is [System.IO.DirectoryInfo]
@@ -542,7 +542,7 @@ function Find-Item {
542542
currentDepth = $folder.currentDepth + 1
543543
}
544544
)
545-
Write-Verbose "Recursing after last matched directory in $($directories.Peek().currentPath)"
545+
Microsoft.PowerShell.Utility\Write-Verbose "Recursing after last matched directory in $($directories.Peek().currentPath)"
546546
}
547547

548548
# if the item does not match the name pattern supplied
@@ -567,17 +567,17 @@ function Find-Item {
567567
# match the file content with the regular expression pattern
568568
Search-FileContent -FilePath ($_.FullName) -Pattern $using:Pattern
569569
)) {
570-
Write-Verbose "Found $($_.FullName)"
570+
Microsoft.PowerShell.Utility\Write-Verbose "Found $($_.FullName)"
571571

572572
# output FileInfo/DirectoryInfo objects if -PassThru is specified
573573
if ($using:PassThru) {
574574

575-
Write-Output $_
575+
Microsoft.PowerShell.Utility\Write-Output $_
576576
return;
577577
}
578578

579579
# or output the relative path of the found item
580-
Resolve-Path -Path $_ -Relative -RelativeBasePath:$using:RelativeBasePath
580+
Microsoft.PowerShell.Management\Resolve-Path -Path $_ -Relative -RelativeBasePath:$using:RelativeBasePath
581581
}
582582
}
583583
}
@@ -586,7 +586,7 @@ function Find-Item {
586586

587587
foreach ($currentSearchPhrase in $using:SearchMask) {
588588

589-
Write-Verbose "Processing search pattern: $currentSearchPhrase"
589+
Microsoft.PowerShell.Utility\Write-Verbose "Processing search pattern: $currentSearchPhrase"
590590

591591
if ($null -eq $PSItem) {
592592

Functions/GenXdev.FileSystem/Invoke-Fasti.ps1

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ function Invoke-Fasti {
4545
process {
4646

4747
# process each archive file found in current directory
48-
Get-ChildItem $extensions -File -ErrorAction SilentlyContinue |
49-
ForEach-Object {
48+
Microsoft.PowerShell.Management\Get-ChildItem $extensions -File -ErrorAction SilentlyContinue |
49+
Microsoft.PowerShell.Core\ForEach-Object {
5050

51-
Write-Verbose "Processing archive: $($PSItem.Name)"
51+
Microsoft.PowerShell.Utility\Write-Verbose "Processing archive: $($PSItem.Name)"
5252

5353
# initialize 7zip executable path
5454
$sevenZip = "7z"
@@ -62,23 +62,23 @@ function Invoke-Fasti {
6262
# create extraction directory if it doesn't exist
6363
if ([System.IO.Directory]::exists($extractPath) -eq $false) {
6464

65-
Write-Verbose "Creating directory: $extractPath"
65+
Microsoft.PowerShell.Utility\Write-Verbose "Creating directory: $extractPath"
6666
[System.IO.Directory]::CreateDirectory($extractPath)
6767
}
6868

6969
# verify 7zip installation or attempt to install it
70-
if ((Get-Command $sevenZip -ErrorAction SilentlyContinue).Length -eq 0) {
70+
if ((Microsoft.PowerShell.Core\Get-Command $sevenZip -ErrorAction SilentlyContinue).Length -eq 0) {
7171

7272
$sevenZip = "${env:ProgramFiles}\7-Zip\7z.exe"
7373

7474
if (![IO.File]::Exists($sevenZip)) {
7575

76-
if ((Get-Command winget -ErrorAction SilentlyContinue).Length -eq 0) {
76+
if ((Microsoft.PowerShell.Core\Get-Command winget -ErrorAction SilentlyContinue).Length -eq 0) {
7777

7878
throw "You need to install 7zip or winget first"
7979
}
8080

81-
Write-Verbose "Installing 7-Zip via winget..."
81+
Microsoft.PowerShell.Utility\Write-Verbose "Installing 7-Zip via winget..."
8282
winget install 7zip
8383

8484
if (![IO.File]::Exists($sevenZip)) {
@@ -89,7 +89,7 @@ function Invoke-Fasti {
8989
}
9090

9191
# extract archive contents
92-
Write-Verbose "Extracting to: $extractPath"
92+
Microsoft.PowerShell.Utility\Write-Verbose "Extracting to: $extractPath"
9393
$pwparam = if ($Password) { "-p$Password" } else { "" }
9494
if ([string]::IsNullOrWhiteSpace($Password)) {
9595

@@ -104,11 +104,11 @@ function Invoke-Fasti {
104104
if ($?) {
105105

106106
try {
107-
Write-Verbose "Removing original archive: $zipFile"
108-
Remove-Item "$zipFile" -Force -ErrorAction silentlycontinue
107+
Microsoft.PowerShell.Utility\Write-Verbose "Removing original archive: $zipFile"
108+
Microsoft.PowerShell.Management\Remove-Item "$zipFile" -Force -ErrorAction silentlycontinue
109109
}
110110
catch {
111-
Write-Verbose "Failed to remove original archive"
111+
Microsoft.PowerShell.Utility\Write-Verbose "Failed to remove original archive"
112112
}
113113
}
114114
}

0 commit comments

Comments
 (0)