PSCredentialStore/src/Store/Test-CredentialStore.ps1
Marco Blessing 7708df9b66
Update pwsh style to latest community standards (#52)
* update pwsh style in store files

* update pwsh style in item files

* update pwsh style in connection files

* update pwsh style in certificate files

* update pwsh style in private files

* update pwsh style in drone helper

* update meta

* fix pwsh style

* fix output type

* fix typo in OutputType

* update appveyor build mode

* debugging build mode

* wip

* test windows pipeline

* fix typo

* simplify drone setup

* update readme

* remove deprecated cicd setup

* update pwsh style
2022-06-28 08:56:33 +02:00

59 lines
1.7 KiB
PowerShell

function Test-CredentialStore {
<#
.SYNOPSIS
Returns the credential store state.
.DESCRIPTION
Use this script to test your credential store. For now it only checks if
the file exists.
.PARAMETER Path
Define a custom path to a shared CredentialStore.
.PARAMETER Shared
Switch to shared mode with this param. This enforces the command to work with a shared CredentialStore which
can be decrypted across systems.
.EXAMPLE
Test-CredentialStore -eq $true
#>
[CmdletBinding(DefaultParameterSetName = 'Private')]
[OutputType([bool])]
param (
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
[string]$Path,
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
[switch]$Shared
)
begin {}
process {
# Set the CredentialStore for private, shared or custom mode.
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
if ($PSCmdlet.ParameterSetName -eq 'Private') {
$Path = Get-DefaultCredentialStorePath
}
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
if (!($PSBoundParameters.ContainsKey('Path'))) {
$Path = Get-DefaultCredentialStorePath -Shared
}
}
Write-Verbose -Message ("Path is: {0}" -f $Path)
if (Test-Path $Path) {
Write-Verbose 'CredentialStore in given path found.'
Write-Output $true
}
else {
Write-Verbose 'The given CredentialStore does not exist!'
Write-Output $false
}
}
end {}
}