From 9f7cac860ecac48a90f435e92bda7658ce53ee47 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Tue, 14 Jun 2022 09:19:59 +0200 Subject: [PATCH] update pwsh style in private files --- src/Private/Get-CSPfxCertificate.ps1 | 11 ++--------- src/Private/Get-DefaultCredentialStorePath.ps1 | 15 ++++----------- src/Private/Get-ModuleBase.ps1 | 17 ++++------------- src/Private/Get-RandomAESKey.ps1 | 14 +++----------- src/Private/Get-TempDir.ps1 | 14 +++----------- src/Private/Import-CSPfxCertificate.ps1 | 14 ++++---------- src/Private/Resolve-Dependency.ps1 | 14 +++----------- src/Private/Test-CSPfxCertificate.ps1 | 11 ++--------- src/Private/Test-Module.ps1 | 13 +++---------- 9 files changed, 28 insertions(+), 95 deletions(-) diff --git a/src/Private/Get-CSPfxCertificate.ps1 b/src/Private/Get-CSPfxCertificate.ps1 index 9afe659..e3e384b 100644 --- a/src/Private/Get-CSPfxCertificate.ps1 +++ b/src/Private/Get-CSPfxCertificate.ps1 @@ -23,18 +23,11 @@ function Get-CSPfxCertificate { .EXAMPLE Get-CSPfxCertificate -Thumbprint '12345678' -StoreName 'My' -StoreLocation 'CurrentUser' - - .NOTES - - File Name : Get-CSPfxCertificate.ps1 - - Author : Marco Blessing - marco.blessing@googlemail.com - - Requires : - - .LINK - https://github.com/OCram85/PSCredentialStore #> + [CmdletBinding()] [OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2])] - param( + param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true)] [ValidateNotNullOrEmpty()] [string[]]$Thumbprint, diff --git a/src/Private/Get-DefaultCredentialStorePath.ps1 b/src/Private/Get-DefaultCredentialStorePath.ps1 index 2ee5dc5..f235ce3 100644 --- a/src/Private/Get-DefaultCredentialStorePath.ps1 +++ b/src/Private/Get-DefaultCredentialStorePath.ps1 @@ -14,23 +14,16 @@ function Get-DefaultCredentialStorePath { .EXAMPLE $Path = Get-DefaultCredentialStorePath - - .NOTES - - File Name : Get-DefaultCredentialStorePath.ps1 - - Author : Marco Blessing - marco.blessing@googlemail.com - - Requires : - - .LINK - https://github.com/OCram85/PSCredentialStore #> + [CmdletBinding()] [OutputType([string])] - param( + param ( [Parameter(Mandatory = $false)] [switch]$Shared ) - begin { } + begin {} process { if ($Shared.IsPresent) { @@ -57,5 +50,5 @@ function Get-DefaultCredentialStorePath { } } - end { } + end {} } diff --git a/src/Private/Get-ModuleBase.ps1 b/src/Private/Get-ModuleBase.ps1 index acb2451..968f54b 100644 --- a/src/Private/Get-ModuleBase.ps1 +++ b/src/Private/Get-ModuleBase.ps1 @@ -6,24 +6,15 @@ function Get-ModuleBase { .DESCRIPTION This is just a wrapper for enabling pester tests. - .OUTPUTS Returns the base path as string - - .NOTES - - File Name : Get-ModuleBase.ps1 - - Author : Marco Blessing - marco.blessing@googlemail.com - - Requires : - - .LINK - https://github.com/OCram85/PSCredentialStore #> [CmdletBinding()] - [OutputType()] - param() - begin { } + [OutputType([string])] + param () + begin {} process { return $MyInvocation.MyCommand.Module.ModuleBase } - end { } + end {} } diff --git a/src/Private/Get-RandomAESKey.ps1 b/src/Private/Get-RandomAESKey.ps1 index aff07b5..868300d 100644 --- a/src/Private/Get-RandomAESKey.ps1 +++ b/src/Private/Get-RandomAESKey.ps1 @@ -14,21 +14,13 @@ function Get-RandomAESKey { .EXAMPLE .\Get-RandomAESKey - - .NOTES - - File Name : Get-RandomAESKey.ps1 - - Author : Marco Blessing - marco.blessing@googlemail.com - - Requires : - - .LINK - https://github.com/OCram85/PSCredentialStore #> [CmdletBinding()] [OutputType([byte[]])] - param() + param () - begin { } + begin {} process { $key = [byte[]]::new(32) @@ -40,5 +32,5 @@ function Get-RandomAESKey { } } - end { } + end {} } diff --git a/src/Private/Get-TempDir.ps1 b/src/Private/Get-TempDir.ps1 index b3db4d9..9406698 100644 --- a/src/Private/Get-TempDir.ps1 +++ b/src/Private/Get-TempDir.ps1 @@ -13,21 +13,13 @@ function Get-TempDir { .EXAMPLE Get-TempDir - - .NOTES - - File Name : Get-TempDir.ps1 - - Author : Marco Blessing - marco.blessing@googlemail.com - - Requires : - - .LINK - https://github.com/OCram85/PSCredentialStore #> [CmdletBinding()] [OutputType([string])] - param() - begin { + param () - } + begin {} + process { if ($IsLinux) { return (Resolve-Path -Path '/tmp/').Path diff --git a/src/Private/Import-CSPfxCertificate.ps1 b/src/Private/Import-CSPfxCertificate.ps1 index b261c49..eb9f93f 100644 --- a/src/Private/Import-CSPfxCertificate.ps1 +++ b/src/Private/Import-CSPfxCertificate.ps1 @@ -22,18 +22,10 @@ function Import-CSPfxCertificate { .EXAMPLE Import-CSPfxCertificate -Path (Join-Path -Path $Env:APPDATA -ChildPath '/PSCredentialStore.pfx') - - .NOTES - File Name : Import-CSPfxCertificate.ps1 - Author : Marco Blessing - marco.blessing@googlemail.com - Requires : - - .LINK - https://github.com/OCram85/PSCredentialStore #> + [CmdletBinding()] - [OutputType()] - param( + param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string]$Path, @@ -68,6 +60,7 @@ function Import-CSPfxCertificate { )] [string]$OpenFlags = 'ReadWrite' ) + begin { $Store = [System.Security.Cryptography.X509Certificates.X509Store]::new($StoreName, $StoreLocation) try { @@ -77,6 +70,7 @@ function Import-CSPfxCertificate { $_.Exception.Message | Write-Error -ErrorAction Stop } } + process { try { $cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new( diff --git a/src/Private/Resolve-Dependency.ps1 b/src/Private/Resolve-Dependency.ps1 index 4b82922..cf86b40 100644 --- a/src/Private/Resolve-Dependency.ps1 +++ b/src/Private/Resolve-Dependency.ps1 @@ -38,16 +38,9 @@ function Resolve-Dependency { If (-not (Resolve-Dependency -Name 'VMware')) { Write-Error -Message ("Could not resolve the optional dependencies defined for {0}" -f 'VMware') -ErrorAction 'Stop' } - - .NOTES - - File Name : ResolveDependency.ps1 - - Author : Marco Blessing - marco.blessing@googlemail.com - - Requires : - - .LINK - https://github.com/OCram85/PSCredentialStore #> - [OutputType([bool])] + + [OutputType([boolean])] [CmdletBinding()] param ( [Parameter(Mandatory = $true)] @@ -86,6 +79,5 @@ function Resolve-Dependency { } } - end { - } + end {} } diff --git a/src/Private/Test-CSPfxCertificate.ps1 b/src/Private/Test-CSPfxCertificate.ps1 index d03fdf5..7e16d53 100644 --- a/src/Private/Test-CSPfxCertificate.ps1 +++ b/src/Private/Test-CSPfxCertificate.ps1 @@ -23,17 +23,10 @@ function Test-CSPfxCertificate { .EXAMPLE Test-CSPfxCertificate -Thumbprint '12345678' -StoreName 'My' -StoreLocation 'CurrentUser' - - .NOTES - File Name : Test-CSPfxCertificate.ps1 - Author : Marco Blessing - marco.blessing@googlemail.com - Requires : - - .LINK - https://github.com/OCram85/PSCredentialStore #> + [CmdletBinding()] - [OutputType([bool])] + [OutputType([boolean])] param( [Parameter(Mandatory = $true, ValueFromPipeline = $true)] [ValidateNotNullOrEmpty()] diff --git a/src/Private/Test-Module.ps1 b/src/Private/Test-Module.ps1 index ab68198..61ed158 100644 --- a/src/Private/Test-Module.ps1 +++ b/src/Private/Test-Module.ps1 @@ -32,14 +32,6 @@ function Test-Module { .EXAMPLE .\Test-Dependency -Name 'VMware.PowerCLI' -Type 'Module' -StopIfFails - - .NOTES - - File Name : Test-Module.ps1 - - Author : Marco Blessing - marco.blessing@googlemail.com - - Requires : - - .LINK - https://github.com/OCram85/PSCredentialStore #> [OutputType([bool])] [CmdletBinding()] @@ -56,7 +48,8 @@ Could not find the required {0} called {1}. Please install the required {0} to r [Parameter(Mandatory = $false)] [switch]$StopIfFails ) - begin { } + + begin {} process { $Message = $MessagePattern -f $Type, $Name @@ -73,5 +66,5 @@ Could not find the required {0} called {1}. Please install the required {0} to r } } - end { } + end {} }