Update pwsh style to latest community standards #52

Merged
OCram85 merged 19 commits from rework2022 into master 2022-06-28 08:56:33 +02:00
6 changed files with 30 additions and 76 deletions
Showing only changes of commit 8cab0aeac6 - Show all commits

View File

@ -20,15 +20,8 @@ function Get-CSCertificate {
.EXAMPLE .EXAMPLE
Get-CSCertificate -Type 'Shared' -Thumbprint '12334456' Get-CSCertificate -Type 'Shared' -Thumbprint '12334456'
.NOTES
- File Name : Get-CSCertificate.ps1
- Author : Marco Blessing - marco.blessing@googlemail.com
- Requires :
.LINK
https://github.com/OCram85/PSCredentialStore
#> #>
[CmdletBinding()] [CmdletBinding()]
[OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2])] [OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2])]
param ( param (
@ -42,8 +35,8 @@ function Get-CSCertificate {
[string]$Thumbprint [string]$Thumbprint
) )
begin { begin {}
}
process { process {
if ($Type -eq 'Private') { if ($Type -eq 'Private') {
Get-CSPfXCertificate -Thumbprint $Thumbprint -StoreName 'My' -StoreLocation 'CurrentUser' Get-CSPfXCertificate -Thumbprint $Thumbprint -StoreName 'My' -StoreLocation 'CurrentUser'
@ -69,6 +62,5 @@ function Get-CSCertificate {
} }
} }
} }
end { end {}
}
} }

View File

@ -21,17 +21,9 @@ function Import-CSCertificate {
.EXAMPLE .EXAMPLE
Import-CSCertificate -Type 'Private' -Path (Join-Path -Path $Env:APPDATA -ChildItem 'PfxCertificate.pfx') Import-CSCertificate -Type 'Private' -Path (Join-Path -Path $Env:APPDATA -ChildItem 'PfxCertificate.pfx')
.NOTES
- File Name : Import-CSCertificate.ps1
- Author : Marco Blessing - marco.blessing@googlemail.com
- Requires :
.LINK
https://github.com/OCram85/PSCredentialStore
#> #>
[CmdletBinding()] [CmdletBinding()]
[OutputType()]
param ( param (
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]

View File

@ -35,15 +35,8 @@ function New-CSCertAttribute {
.EXAMPLE .EXAMPLE
New-CSCertAttribute -Country 'DE' -State 'BW' -City 'Karlsruhe' -Organization 'AwesomeIT' -OrganizationalUnitName '' -CommonName 'MyPrivateCert' New-CSCertAttribute -Country 'DE' -State 'BW' -City 'Karlsruhe' -Organization 'AwesomeIT' -OrganizationalUnitName '' -CommonName 'MyPrivateCert'
.NOTES
- File Name : New-CSCertAttribute.ps1
- Author : Marco Blessing - marco.blessing@googlemail.com
- Requires :
.LINK
https://github.com/OCram85/PSCredentialStore
#> #>
[CmdletBinding()] [CmdletBinding()]
[OutputType('PSCredentialStore.Certificate.Attribute')] [OutputType('PSCredentialStore.Certificate.Attribute')]
param ( param (
@ -76,9 +69,8 @@ function New-CSCertAttribute {
[ValidateNotNull()] [ValidateNotNull()]
[int]$Days = 365 [int]$Days = 365
) )
begin { begin {}
}
process { process {
return [PSCustomObject]@{ return [PSCustomObject]@{
PSTypeName = 'PSCredentialStore.Certificate.Attribute' PSTypeName = 'PSCredentialStore.Certificate.Attribute'
@ -94,6 +86,5 @@ function New-CSCertAttribute {
Days = $Days Days = $Days
} }
} }
end { end {}
}
} }

View File

@ -23,15 +23,8 @@ function New-CSCertificate {
.EXAMPLE .EXAMPLE
New-CSCertificate -CRTAttribute $CRTAttribute -KeyName './myprivate.key' -CertName './mycert.pfx' New-CSCertificate -CRTAttribute $CRTAttribute -KeyName './myprivate.key' -CertName './mycert.pfx'
.NOTES
- File Name : New-CSCertificate.ps1
- Author : Marco Blessing - marco.blessing@googlemail.com
- Requires :
.LINK
https://github.com/OCram85/PSCredentialStore
#> #>
[CmdletBinding(SupportsShouldProcess = $true)] [CmdletBinding(SupportsShouldProcess = $true)]
[OutputType()] [OutputType()]
param ( param (
@ -70,6 +63,7 @@ function New-CSCertificate {
$Env:OPENSSL_CONF = Join-Path $ModuleBase -ChildPath '/openssl.conf' $Env:OPENSSL_CONF = Join-Path $ModuleBase -ChildPath '/openssl.conf'
} }
process { process {
$SubjPattern = "/C={0}/ST={1}/L={2}/O={3}/OU={4}/CN={5}" $SubjPattern = "/C={0}/ST={1}/L={2}/O={3}/OU={4}/CN={5}"
$SubjValues = @( $SubjValues = @(

View File

@ -17,17 +17,10 @@ function Test-CSCertificate {
.EXAMPLE .EXAMPLE
Test-CSCertificate -Type 'Shared' Test-CSCertificate -Type 'Shared'
.NOTES
- File Name : Test-CSCertificate.ps1
- Author : Marco Blessing - marco.blessing@googlemail.com
- Requires :
.LINK
https://github.com/OCram85/PSCredentialStore
#> #>
[CmdletBinding()] [CmdletBinding()]
[OutputType([bool])] [OutputType([boolean])]
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]

View File

@ -26,34 +26,26 @@ function Use-CSCertificate {
.EXAMPLE .EXAMPLE
Use-CSCertificate -Path 'C:\cert.pfx' Use-CSCertificate -Path 'C:\cert.pfx'
.NOTES
File Name : Use-CSCertificate.ps1
Author : Marco Blessing - marco.blessing@googlemail.com
Requires :
.LINK
https://github.com/OCram85/PSCredentialStore
#> #>
[CmdletBinding(DefaultParameterSetName = "Private")]
[OutputType()] [CmdletBinding(DefaultParameterSetName = 'Private')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "")]
param ( param (
[Parameter(Mandatory = $true, ParameterSetName = "Private")] [Parameter(Mandatory = $true, ParameterSetName = 'Private')]
[Parameter(Mandatory = $true, ParameterSetName = "Shared")] [Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[string]$Path, [string]$Path,
[Parameter(Mandatory = $false, ParameterSetName = "Shared")] [Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[string]$CredentialStore, [string]$CredentialStore,
[Parameter(Mandatory = $true, ParameterSetName = "Shared")] [Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
[switch]$Shared, [switch]$Shared,
[Parameter(Mandatory = $false, ParameterSetName = "Private")] [Parameter(Mandatory = $false, ParameterSetName = 'Private')]
[Parameter(Mandatory = $false, ParameterSetName = "Shared")] [Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
[Switch]$UseCertStore [switch]$UseCertStore
) )
begin {} begin {}
@ -74,11 +66,11 @@ function Use-CSCertificate {
} }
try { try {
if ($PSCmdlet.ParameterSetName -eq "Private") { if ($PSCmdlet.ParameterSetName -eq 'Private') {
$StorePath = Get-DefaultCredentialStorePath $StorePath = Get-DefaultCredentialStorePath
$CS = Get-CredentialStore $CS = Get-CredentialStore
} }
elseif ($PSCmdlet.ParameterSetName -eq "Shared" ) { elseif ($PSCmdlet.ParameterSetName -eq 'Shared' ) {
if (!($PSBoundParameters.ContainsKey('CredentialStore'))) { if (!($PSBoundParameters.ContainsKey('CredentialStore'))) {
$StorePath = Get-DefaultCredentialStorePath -Shared $StorePath = Get-DefaultCredentialStorePath -Shared
$CS = Get-CredentialStore -Shared $CS = Get-CredentialStore -Shared