update pwsh style in store files
This commit is contained in:
parent
739c8cb9b0
commit
b302cd0b0c
@ -23,35 +23,28 @@ function Get-CredentialStore {
|
|||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
$CSContent = Get-CredentialStore -Path "C:\TMP\mystore.json"
|
$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")]
|
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||||
[OutputType("PSCredentialStore.Store")]
|
[OutputType("PSCredentialStore.Store")]
|
||||||
param(
|
param (
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||||
|
|
||||||
[string]$Path,
|
[string]$Path,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||||
[switch]$Shared
|
[switch]$Shared
|
||||||
)
|
)
|
||||||
|
|
||||||
begin { }
|
begin {}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
# Set the CredentialStore for private, shared or custom mode.
|
# Set the CredentialStore for private, shared or custom mode.
|
||||||
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
||||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||||
$Path = Get-DefaultCredentialStorePath
|
$Path = Get-DefaultCredentialStorePath
|
||||||
}
|
}
|
||||||
elseif ($PSCmdlet.ParameterSetName -eq "Shared") {
|
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||||
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
||||||
$Path = Get-DefaultCredentialStorePath -Shared
|
$Path = Get-DefaultCredentialStorePath -Shared
|
||||||
}
|
}
|
||||||
@ -61,26 +54,26 @@ function Get-CredentialStore {
|
|||||||
try {
|
try {
|
||||||
$FileContent = Get-Content -Path $Path -Raw
|
$FileContent = Get-Content -Path $Path -Raw
|
||||||
$CS = ConvertFrom-Json $FileContent
|
$CS = ConvertFrom-Json $FileContent
|
||||||
$CS.PSObject.TypeNames.Insert(0, "PSCredentialStore.Store")
|
$CS.PSObject.TypeNames.Insert(0, 'PSCredentialStore.Store')
|
||||||
return $CS
|
Write-Output $CS
|
||||||
}
|
}
|
||||||
catch [System.Exception] {
|
catch [System.Exception] {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unknown CredentialStore format. Invalid JSON file."
|
Message = 'Unknown CredentialStore format. Invalid JSON file.'
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Could not find the CredentialStore."
|
Message = 'Could not find the CredentialStore.'
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end { }
|
end {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,49 +49,38 @@ function New-CredentialStore {
|
|||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
New-CredentialStore -Shared -Path "C:\TMP\CredentialStore.json"
|
New-CredentialStore -Shared -Path "C:\TMP\CredentialStore.json"
|
||||||
# Creates a new shared CredentialStore in the given location.
|
# Creates a new shared CredentialStore in the given location.
|
||||||
|
|
||||||
.NOTES
|
|
||||||
- File Name : New-CredentialStore.ps1
|
|
||||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
- Requires :
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "Private")]
|
[CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'Private')]
|
||||||
[OutputType("PSCredentialStore.Store")]
|
[OutputType('PSCredentialStore.Store')]
|
||||||
param(
|
param (
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||||
[switch]$Shared,
|
[switch]$Shared,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[System.IO.FileInfo]$Path,
|
[System.IO.FileInfo]$Path,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||||
[Switch]$Force,
|
[switch]$Force,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||||
[Switch]$PassThru,
|
[switch]$PassThru,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||||
[Switch]$SkipPFXCertCreation,
|
[switch]$SkipPFXCertCreation,
|
||||||
|
|
||||||
[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 {
|
||||||
# Lets get the current Date in a human readable format.
|
# Lets get the current Date in a human readable format.
|
||||||
$CurrentDate = Get-Date -UFormat "%Y-%m-%d %H:%M:%S"
|
$CurrentDate = Get-Date -Format 'u'
|
||||||
|
|
||||||
# Set latest Credential Store version
|
|
||||||
# Set-Variable -Name "CSVersion" -Value "2.0.0" -Option Constant -Scope
|
|
||||||
|
|
||||||
# test if the path input is a valid file path
|
# test if the path input is a valid file path
|
||||||
if ($PSCmdlet.MyInvocation.BoundParameters.ContainsKey('Path')) {
|
if ($PSCmdlet.MyInvocation.BoundParameters.ContainsKey('Path')) {
|
||||||
@ -108,7 +97,7 @@ function New-CredentialStore {
|
|||||||
$ErrorParams = @{
|
$ErrorParams = @{
|
||||||
ErrorAction = 'Stop'
|
ErrorAction = 'Stop'
|
||||||
Exception = [System.IO.InvalidDataException]::new(
|
Exception = [System.IO.InvalidDataException]::new(
|
||||||
'Your provided path does not contain the required file extension .json !'
|
'Your provided path does not contain the required file extension .json!'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Write-Error @ErrorParams
|
Write-Error @ErrorParams
|
||||||
@ -119,17 +108,17 @@ function New-CredentialStore {
|
|||||||
process {
|
process {
|
||||||
# Set the CredentialStore for private, shared or custom mode.
|
# Set the CredentialStore for private, shared or custom mode.
|
||||||
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
||||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||||
$Path = Get-DefaultCredentialStorePath
|
$Path = Get-DefaultCredentialStorePath
|
||||||
}
|
}
|
||||||
elseif ($PSCmdlet.ParameterSetName -eq "Shared") {
|
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||||
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
||||||
$Path = Get-DefaultCredentialStorePath -Shared
|
$Path = Get-DefaultCredentialStorePath -Shared
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test if in the CredentialStore already exists.
|
# Test if in the CredentialStore already exists.
|
||||||
Write-Verbose "Test if there is already a credential store."
|
Write-Verbose 'Test if there is already a credential store.'
|
||||||
if ((Test-Path -Path $Path) -and ($Force -ne $true)) {
|
if ((Test-Path -Path $Path) -and ($Force -ne $true)) {
|
||||||
$ErrorParams = @{
|
$ErrorParams = @{
|
||||||
ErrorAction = 'Stop'
|
ErrorAction = 'Stop'
|
||||||
@ -211,11 +200,11 @@ function New-CredentialStore {
|
|||||||
Type = $null
|
Type = $null
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($PSCmdlet.ParameterSetName -eq "Shared") {
|
if ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||||
$ObjProperties.Type = "Shared"
|
$ObjProperties.Type = 'Shared'
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$ObjProperties.Type = "Private"
|
$ObjProperties.Type = 'Private'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $SkipPFXCertCreation.IsPresent) {
|
if (! $SkipPFXCertCreation.IsPresent) {
|
||||||
|
@ -17,35 +17,26 @@ function Test-CredentialStore {
|
|||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Test-CredentialStore -eq $true
|
Test-CredentialStore -eq $true
|
||||||
|
|
||||||
.NOTES
|
|
||||||
- File Name : Test-CredentialStore.ps1
|
|
||||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
- Requires :
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||||
param(
|
[OutputBinding([string])]
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
param (
|
||||||
|
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||||
[string]$Path,
|
[string]$Path,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||||
[switch]$Shared
|
[switch]$Shared
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {}
|
||||||
# Set latest Credential Store version
|
|
||||||
#Set-Variable -Name "CSVersion" -Value "2.0.0" -Option Constant
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
process {
|
||||||
# Set the CredentialStore for private, shared or custom mode.
|
# Set the CredentialStore for private, shared or custom mode.
|
||||||
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
||||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||||
$Path = Get-DefaultCredentialStorePath
|
$Path = Get-DefaultCredentialStorePath
|
||||||
}
|
}
|
||||||
elseif ($PSCmdlet.ParameterSetName -eq "Shared") {
|
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||||
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
||||||
$Path = Get-DefaultCredentialStorePath -Shared
|
$Path = Get-DefaultCredentialStorePath -Shared
|
||||||
}
|
}
|
||||||
@ -53,15 +44,15 @@ function Test-CredentialStore {
|
|||||||
Write-Verbose -Message ("Path is: {0}" -f $Path)
|
Write-Verbose -Message ("Path is: {0}" -f $Path)
|
||||||
|
|
||||||
if (Test-Path $Path) {
|
if (Test-Path $Path) {
|
||||||
Write-Verbose "CredentialStore in given path found."
|
Write-Verbose 'CredentialStore in given path found.'
|
||||||
return $true
|
Write-Output $true
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Verbose "The given CredentialStore does not exist!"
|
Write-Verbose 'The given CredentialStore does not exist!'
|
||||||
return $false
|
Write-Output $false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end { }
|
end {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user