Skip to content

Commit 635fc55

Browse files
committed
v2.4
1 parent 6d4cae7 commit 635fc55

21 files changed

+48
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
function Assert-PsOneFolderExists
2+
{
3+
<#
4+
.SYNOPSIS
5+
Makes sure the specified folder(s) exist
6+
7+
.DESCRIPTION
8+
If a folder does not exist, it will be created.
9+
10+
.EXAMPLE
11+
($Path = 'C:\test') | Assert-PsOneFolderExists
12+
Makes sure the folder c:\test exists. If it is still missing, it will be created.
13+
14+
.EXAMPLE
15+
'C:\test','c:\test2' | Assert-PsOneFolderExists
16+
Makes sure the folders. If a folder is still missing, it will be created.
17+
18+
.EXAMPLE
19+
Assert-PsOneFolderExists -Path 'C:\test','c:\test2'
20+
Makes sure the folders. If a folder is still missing, it will be created.
21+
22+
.LINK
23+
https://powershell.one
24+
#>
25+
26+
27+
param
28+
(
29+
[Parameter(Mandatory,HelpMessage='Path to folder that must exist',ValueFromPipeline)]
30+
[string[]]
31+
$Path
32+
)
33+
34+
process
35+
{
36+
foreach($_ in $Path)
37+
{
38+
$exists = Test-Path -Path $_ -PathType Container
39+
if (!$exists) {
40+
Write-Warning -Message "$_ did not exist. Folder created."
41+
$null = New-Item -Path $_ -ItemType Directory
42+
}
43+
}
44+
}
45+
}

PSOneTools/2.2/Get-PSOneFileHash.ps1 renamed to PSOneTools/2.4/Get-PSOneFileHash.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
$BufferSize = 32KB,
7878

7979
[Security.Cryptography.HashAlgorithmName]
80+
[ValidateSet('MD5','SHA1','SHA256','SHA384','SHA512')]
8081
# hash algorithm to use. The fastest algorithm is SHA1. MD5 is second best
8182
# in terms of speed. Slower algorithms provide more secure hashes with a
8283
# lesser chance of duplicates with different content
@@ -140,7 +141,6 @@
140141
# or whether initializing the hash engine in the begin() block is safe.
141142
try
142143
{
143-
$algorithmName = [Security.Cryptography.HashAlgorithmName]::SHA1
144144
$algorithm = [Security.Cryptography.HashAlgorithm]::Create($algorithmName)
145145
}
146146
catch
@@ -250,4 +250,4 @@
250250
# return result for the file
251251
return $result
252252
}
253-
}
253+
}
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.

PSOneTools/2.2/module.psm1 renamed to PSOneTools/2.4/module.psm1

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# LOADING ALL FUNCTION DEFINITIONS:
1010

11+
. $PSScriptRoot\Assert-PSOneFolderExists.ps1
1112
. $PSScriptRoot\Test-PSOnePort.ps1
1213
. $PSScriptRoot\Test-PSOnePing.ps1
1314
. $PSScriptRoot\Foreach-ObjectFast.ps1

0 commit comments

Comments
 (0)