forked from OCram85/PSCredentialStore
Publish Pre-release (#1)
* adds basic module layout * fix module manifest encoding * fix callsign in appveyor helper * adds challenge file related functions * adds connection manager functions * adds Test-ChallengeFile * adds item related functions * adds store related functions * adds cSpell dictionary * adds CredentialStore related Pester tests * [WIP] test Pester file * fix typo * adds file dependencies * [WIP] fix pester tests * fix exception state * [WIP] add file dependencies * fix gitkeep filename * set constant debug module version string * adds Pester Tests for New-CredentialStoreItem * adds basic readme file * adds functions to export; adds meta data * adds vscode debug config * adds test for optional dependencies * [WIP] Implements optional dependency test * adds taskrunner definitions * adds CBH * add gitignore file * adds basic Build tasks * typo fixed * adds build folder to ignore list * adds Cisco and NetApp opt dependencies * adds build task * fix end of line dequence * remove task.json error * adds sources for optional modules * enables Pester and posh-git * prepare pre-release
This commit is contained in:
69
src/Store/Get-CredentialStore.ps1
Normal file
69
src/Store/Get-CredentialStore.ps1
Normal file
@ -0,0 +1,69 @@
|
||||
function Get-CredentialStore {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Reads the complete content of the credential store and returns it as a new object.
|
||||
|
||||
.DESCRIPTION
|
||||
The content is in a raw format. It means there is no transformation to the different credential types.
|
||||
You can not use the object properties to connect with remote host. Therefore please use
|
||||
Get-CredentialStoreItem.
|
||||
|
||||
.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.
|
||||
|
||||
.INPUTS
|
||||
[None]
|
||||
|
||||
.OUTPUTS
|
||||
[PSObject] Returns the credential store content as PSObject.
|
||||
|
||||
.EXAMPLE
|
||||
$CSContent = Get-CredentialStore -Path "C:\TMP\mystore.json"
|
||||
|
||||
.NOTES
|
||||
File Name : Get-CredentialStore.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
||||
param(
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[string]$Path = "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[switch]$Shared
|
||||
)
|
||||
|
||||
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||
$Path = "{0}\CredentialStore.json" -f $env:APPDATA
|
||||
}
|
||||
|
||||
if (Test-CredentialStore -Path $Path) {
|
||||
try {
|
||||
$FileContent = Get-Content -Path $Path -Raw
|
||||
ConvertFrom-Json $FileContent
|
||||
}
|
||||
catch [System.Exception] {
|
||||
$MessageParams = @{
|
||||
Message = "Unknown CredentialStore format. Invalid JSON file."
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
else {
|
||||
$MessageParams = @{
|
||||
Message = "Could not find the CredentialStore."
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user