Marco Blessing
fdc6651588
## About ## Content (Micro Commits) * fixes #38 * fixes #44 * Implement precise lookup hierarchy (fixes #43) * align pester test with #43 logic * split cert functions * use new cert functions for save an lookup * fix pester tests * [wip] * fix var name ref * fix exports * fix cert store location for windows shared mode * fix mandatory params * fix accidentially removed code block * add basic cert pester pests * remove old docs * update cbh blocks * update cbh blocks * update docs * move .net wrapper forpfx files * do not export .net wrapper functions * update docs * rename tests * fix private functions location * - fixes #44: FTP connection * add link to reference * add format files * add preview version shield * update markdown help files (platyps) * add emoji images in captions * fix typos * fix typos * fix typo * prepare version numbers
77 lines
2.3 KiB
PowerShell
77 lines
2.3 KiB
PowerShell
function Test-CSCertificate {
|
|
<#
|
|
.SYNOPSIS
|
|
Tests if the linked certificate is store ein the specified cert stores.
|
|
|
|
.DESCRIPTION
|
|
Test-CSCertificate should be an easy high level test for the linked certificate.
|
|
|
|
.PARAMETER Type
|
|
Select between 'Private' or 'Shared'.
|
|
|
|
.INPUTS
|
|
[None]
|
|
|
|
.OUTPUTS
|
|
[bool]
|
|
|
|
.EXAMPLE
|
|
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()]
|
|
[OutputType([bool])]
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[ValidateNotNullOrEmpty()]
|
|
[ValidateSet('Private', 'Shared')]
|
|
[string]$Type
|
|
)
|
|
begin {
|
|
if ($Type -eq 'Private') {
|
|
$CS = Get-CredentialStore
|
|
}
|
|
elseif ($Type -eq 'Shared') {
|
|
$CS = Get-CredentialStore -Shared
|
|
}
|
|
if ($null -ne $CS.PfxCertificate) {
|
|
Write-Warning 'There is a Pfx certificate file linked in the store. Certificates saved in the Cert store will be ignored!'
|
|
}
|
|
|
|
}
|
|
process {
|
|
if ($Type -eq 'Private') {
|
|
$cert = Get-CSPfXCertificate -Thumbprint $CS.Thumbprint -StoreName 'My' -StoreLocation 'CurrentUser'
|
|
}
|
|
elseif ($Type -eq 'Shared') {
|
|
if ( $isLinux) {
|
|
$cert = Get-CSPfxCertificate -Thumbprint $CS.Thumbprint -StoreName 'My' -StoreLocation 'CurrentUser'
|
|
if ($null -eq $cert) {
|
|
$cert = Get-CSPfxCertificate -Thumbprint $CS.Thumbprint -StoreName 'Root' -StoreLocation 'LocalMachine'
|
|
}
|
|
}
|
|
elseif ( (! $isLinux) -or ($isWindows) ) {
|
|
$cert = Get-CSPfxCertificate -Thumbprint $CS.Thumbprint -StoreName 'My' -StoreLocation 'LocalMachine'
|
|
if ($null -eq $cert) {
|
|
$cert = Get-CSPfxCertificate -Thumbprint $CS.Thumbprint -StoreName 'Root' -StoreLocation 'LocalMachine'
|
|
}
|
|
}
|
|
}
|
|
if ($null -eq $cert) {
|
|
return $false
|
|
}
|
|
else {
|
|
return $true
|
|
}
|
|
}
|
|
end {
|
|
}
|
|
}
|