Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
f2b7910b15 | |||
0b5c9823e0 | |||
42fdb0a373 | |||
2bd250971b | |||
ac6a9d8202 | |||
3d4f53ddc7 | |||
6fce8d6a8c | |||
ddb85d907f | |||
5bdb383627 | |||
a95ba31e40 | |||
1e7dd78c2b | |||
b76668c1e7 | |||
ae62cccfaa | |||
a66e8249db | |||
3d90d912ee | |||
d0b7e53c80 | |||
d4b00a5308 | |||
e3404666d4 | |||
88743e9ffd | |||
c31ee791bb | |||
c45490aefe | |||
4abfec5725 | |||
7708df9b66 | |||
739c8cb9b0 | |||
5983c760b5 | |||
045adbf647 | |||
b6e791f709 | |||
d0a6457d37 | |||
fdc6651588 |
32
.changelog.yml
Normal file
32
.changelog.yml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# The full repository name
|
||||||
|
repo: OCram85/PSCredentialStore
|
||||||
|
|
||||||
|
# Service type (gitea or github)
|
||||||
|
service: gitea
|
||||||
|
|
||||||
|
# Base URL for Gitea instance if using gitea service type (optional)
|
||||||
|
# Default: https://gitea.com
|
||||||
|
base-url: https://gitea.ocram85.com
|
||||||
|
|
||||||
|
# Changelog groups and which labeled PRs to add to each group
|
||||||
|
groups:
|
||||||
|
- name: ✨ FEATURES
|
||||||
|
labels:
|
||||||
|
- feature
|
||||||
|
- name: 📦 META
|
||||||
|
labels:
|
||||||
|
- meta
|
||||||
|
- name: 🐛 BUGFIXES
|
||||||
|
labels:
|
||||||
|
- bug
|
||||||
|
- name: 🛠️ ENHANCEMENTS
|
||||||
|
labels:
|
||||||
|
- enhancement
|
||||||
|
- name: 📚 DOCS
|
||||||
|
labels:
|
||||||
|
- docs
|
||||||
|
- name: 🔖 MISC
|
||||||
|
default: true
|
||||||
|
|
||||||
|
# regex indicating which labels to skip for the changelog
|
||||||
|
skip-labels: skip-changelog|backport\/.+
|
151
.drone.yml
Normal file
151
.drone.yml
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: "Build Pipeline"
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
exclude:
|
||||||
|
- droneDocs/*
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: "Pwsh FileLinter"
|
||||||
|
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
||||||
|
failure: ignore
|
||||||
|
environment:
|
||||||
|
EXCLUDE: "(.exe|.dll|.ico|.gitkeep|Vendor|.Tests.ps1)"
|
||||||
|
commands:
|
||||||
|
- |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y file
|
||||||
|
|
||||||
|
- |
|
||||||
|
pwsh -NonInteractive -c "& {
|
||||||
|
Install-Module -Name 'DroneHelper' -Repository 'PSGallery' -ErrorAction 'Stop' -AllowPrerelease -Force;
|
||||||
|
Import-Module 'DroneHelper' -ErrorAction 'Stop';
|
||||||
|
Invoke-FileLinter
|
||||||
|
}"
|
||||||
|
|
||||||
|
- name: "ScriptAnalyzer"
|
||||||
|
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
||||||
|
failure: ignore
|
||||||
|
commands:
|
||||||
|
- |
|
||||||
|
pwsh -NonInteractive -c "& {
|
||||||
|
Install-Module -Name 'DroneHelper' -Repository 'PSGallery' -ErrorAction 'Stop' -AllowPrerelease -Force;
|
||||||
|
Import-Module -Name 'DroneHelper' -ErrorAction 'Stop';
|
||||||
|
Install-ModuleDependency;
|
||||||
|
Invoke-Linter
|
||||||
|
}"
|
||||||
|
|
||||||
|
- name: "Pester"
|
||||||
|
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
||||||
|
failure: ignore
|
||||||
|
commands:
|
||||||
|
- |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y file
|
||||||
|
|
||||||
|
- |
|
||||||
|
pwsh -NonInteractive -c "& {
|
||||||
|
Install-Module -Name 'DroneHelper' -Repository 'PSGallery' -ErrorAction 'Stop' -AllowPrerelease -Force;
|
||||||
|
Import-Module -Name 'DroneHelper' -ErrorAction 'Stop';
|
||||||
|
Install-ModuleDependency;
|
||||||
|
Invoke-UnitTest -Verbosity 'Detailed' -ExcludeTag 'Integration'
|
||||||
|
}"
|
||||||
|
|
||||||
|
- name: "PRComment"
|
||||||
|
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
||||||
|
failure: ignore
|
||||||
|
environment:
|
||||||
|
GITEA_TOKEN:
|
||||||
|
from_secret: GITEA_TOKEN
|
||||||
|
CUSTOM_PIPELINE_STATE: true
|
||||||
|
LOG_FILES: "build/*.log"
|
||||||
|
commands:
|
||||||
|
- |
|
||||||
|
pwsh -NonInteractive -c "& {
|
||||||
|
Install-Module -Name 'DroneHelper' -Repository 'PSGallery' -ErrorAction 'Stop' -AllowPrerelease -Force;
|
||||||
|
Import-Module -Name 'DroneHelper' -ErrorAction 'Stop';
|
||||||
|
Send-PRComment
|
||||||
|
}"
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
include:
|
||||||
|
- pull_request
|
||||||
|
depends_on:
|
||||||
|
- "Pwsh FileLinter"
|
||||||
|
- "ScriptAnalyzer"
|
||||||
|
- "Pester"
|
||||||
|
|
||||||
|
- name: "buildState"
|
||||||
|
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
||||||
|
commands:
|
||||||
|
- |
|
||||||
|
pwsh -NonInteractive -c "& {
|
||||||
|
Install-Module -Name 'DroneHelper' -Repository 'PSGallery' -ErrorAction 'Stop' -AllowPrerelease -Force;
|
||||||
|
Import-Module -Name 'DroneHelper' -ErrorAction 'Stop';
|
||||||
|
Install-ModuleDependency;
|
||||||
|
Invoke-BuildState
|
||||||
|
}"
|
||||||
|
depends_on:
|
||||||
|
- "PRComment"
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: "Publish Pipeline"
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- "Build Pipeline"
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- tag
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: BuildArtifacts
|
||||||
|
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
||||||
|
#failure: ignore
|
||||||
|
commands:
|
||||||
|
- |
|
||||||
|
pwsh -NonInteractive -c "& {
|
||||||
|
Install-Module -Name 'DroneHelper' -Repository 'PSGallery' -ErrorAction 'Stop' -AllowPrerelease -Force;
|
||||||
|
Import-Module -Name 'DroneHelper' -ErrorAction 'Stop';
|
||||||
|
Install-ModuleDependency;
|
||||||
|
Update-ModuleMeta -Verbose
|
||||||
|
}"
|
||||||
|
- |
|
||||||
|
pwsh -NonInteractive -c "& {
|
||||||
|
Install-Module -Name 'DroneHelper' -Repository 'PSGallery' -ErrorAction 'Stop' -AllowPrerelease -Force;
|
||||||
|
Import-Module -Name 'DroneHelper' -ErrorAction 'Stop';
|
||||||
|
Install-ModuleDependency;
|
||||||
|
New-BuildPackage -Verbose -AdditionalPath @('./src/Vendor', './src/openssl.conf')
|
||||||
|
}"
|
||||||
|
|
||||||
|
- name: GiteaRelease
|
||||||
|
image: plugins/gitea-release
|
||||||
|
settings:
|
||||||
|
api_key:
|
||||||
|
from_secret: GITEA_TOKEN
|
||||||
|
base_url: https://gitea.ocram85.com
|
||||||
|
files:
|
||||||
|
- "bin/${DRONE_REPO_NAME}.zip"
|
||||||
|
- "bin/PSModule.zip"
|
||||||
|
title: "${DRONE_TAG}"
|
||||||
|
note: CHANGELOG.md
|
||||||
|
|
||||||
|
- name: "PublishModule"
|
||||||
|
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
||||||
|
#failure: ignore
|
||||||
|
environment:
|
||||||
|
NuGetToken:
|
||||||
|
from_secret: PSGallery
|
||||||
|
commands:
|
||||||
|
- |
|
||||||
|
pwsh -NonInteractive -c "& {
|
||||||
|
Install-Module -Name 'DroneHelper' -Repository 'PSGallery' -ErrorAction 'Stop' -AllowPrerelease -Force;
|
||||||
|
Import-Module -Name 'DroneHelper' -ErrorAction 'Stop';
|
||||||
|
Install-ModuleDependency;
|
||||||
|
Invoke-Publish -Verbose
|
||||||
|
}"
|
31
.editorconfig
Normal file
31
.editorconfig
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = crlf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
|
||||||
|
[*.yml]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[{.gitattributes,.gitignore,.gitkeep}]
|
||||||
|
end_of_line = lf
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
23
.gitattributes
vendored
23
.gitattributes
vendored
@ -1,2 +1,25 @@
|
|||||||
|
# images
|
||||||
|
*.jpg binary
|
||||||
|
*.jpeg binary
|
||||||
|
*.bmp binary
|
||||||
|
*.tiff binary
|
||||||
|
*.png binary
|
||||||
|
*.svg binary
|
||||||
|
*.ico binary
|
||||||
|
|
||||||
|
# binary files
|
||||||
|
*.exe binary
|
||||||
|
*.dll binary
|
||||||
|
|
||||||
|
# PowerShell specific
|
||||||
|
*.ps1 working-tree-encoding=UTF-8
|
||||||
|
*.psm1 working-tree-encoding=UTF-8
|
||||||
|
*.psd1 working-tree-encoding=UTF-8
|
||||||
|
|
||||||
|
# set markdown to lf for online editing
|
||||||
|
*.md working-tree-encoding=UTF-8
|
||||||
|
|
||||||
|
# Vendor resources config
|
||||||
src/Vendor/libressl255/* filter=lfs diff=lfs merge=lfs -text
|
src/Vendor/libressl255/* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
src/Vendor/libressl/* filter=lfs diff=lfs merge=lfs -text
|
||||||
*.pfx filter=lfs diff=lfs merge=lfs -text
|
*.pfx filter=lfs diff=lfs merge=lfs -text
|
||||||
|
11
.gitea/ISSUE_TEMPLATE.md
Normal file
11
.gitea/ISSUE_TEMPLATE.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
----
|
||||||
|
name: "Default"
|
||||||
|
about: "Use this template if nothing seems to work."
|
||||||
|
title: ":question: "
|
||||||
|
labels:
|
||||||
|
- question
|
||||||
|
----
|
||||||
|
|
||||||
|
#### :grey_question: Simply ask your question here: :grey_question:
|
||||||
|
|
||||||
|
<!-- Take your time an think about your problem.... -->
|
48
.gitea/ISSUE_TEMPLATE/Bug.md
Normal file
48
.gitea/ISSUE_TEMPLATE/Bug.md
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
----
|
||||||
|
name: "Bug"
|
||||||
|
about: "This template is used to report bugs!"
|
||||||
|
title: ":lady_beetle: "
|
||||||
|
labels:
|
||||||
|
- bug
|
||||||
|
----
|
||||||
|
<!--
|
||||||
|
This bug report is ony for content provided in this repository!
|
||||||
|
|
||||||
|
- Make sure you're able to reproduce the error in the lastest version of this package.
|
||||||
|
- Search of already existing issues.
|
||||||
|
- Refer to the known issues and FAQ section.
|
||||||
|
-->
|
||||||
|
|
||||||
|
#### :bomb: Steps to reproduce
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
#### :rocket: Expected behavior
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
#### :boom: Actual behavior
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
#### :notebook: Environment data
|
||||||
|
|
||||||
|
<!-- You can add additional environment data here--->
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
#### :framed_picture: Screenshots
|
||||||
|
|
||||||
|
<!-- Paste your screenshots here. -->
|
||||||
|
|
||||||
|
#### :bookmark: Refs
|
||||||
|
|
||||||
|
<!-- A place for addtional references to othe issues and PRs -->
|
24
.gitea/ISSUE_TEMPLATE/Enhancement.md
Normal file
24
.gitea/ISSUE_TEMPLATE/Enhancement.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
----
|
||||||
|
name: "Enhancement"
|
||||||
|
about: "Wite about new features."
|
||||||
|
title: ":flying_saucer: "
|
||||||
|
labels:
|
||||||
|
- enhancement
|
||||||
|
----
|
||||||
|
<!--
|
||||||
|
This issue template is used to describe whished features.
|
||||||
|
-->
|
||||||
|
|
||||||
|
#### :satellite: Suggestion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### :artificial_satellite: Implementation ideas
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### :framed_picture: Mock-up Images
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### :bookmark: Refs.
|
19
.gitea/PULL_REQUEST_TEMPLATE.md
Normal file
19
.gitea/PULL_REQUEST_TEMPLATE.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#### :book: Summary
|
||||||
|
|
||||||
|
<!-- Provide a summary of your changes. Describe the why and not how. -->
|
||||||
|
|
||||||
|
#### :bookmark_tabs: Test Plan
|
||||||
|
|
||||||
|
> :bulb: Select your test plan for the code changes.
|
||||||
|
|
||||||
|
- [ ] Tested via Drone.io pipeline
|
||||||
|
- [ ] Custom test
|
||||||
|
- [ ] No test plan
|
||||||
|
|
||||||
|
##### Details / Justification
|
||||||
|
|
||||||
|
<!-- Add your test details or justification for missing tests here. -->
|
||||||
|
|
||||||
|
#### :books: Additional Notes
|
||||||
|
|
||||||
|
<!-- A place for additional detail notes. -->
|
18
.gitignore
vendored
18
.gitignore
vendored
@ -1,3 +1,21 @@
|
|||||||
# Don't local track test builds
|
# Don't local track test builds
|
||||||
bin/PSCredentialStore.zip
|
bin/PSCredentialStore.zip
|
||||||
bin/PSCredentialStore/*
|
bin/PSCredentialStore/*
|
||||||
|
|
||||||
|
# Basic ignore patterns
|
||||||
|
*.log
|
||||||
|
*.secret
|
||||||
|
|
||||||
|
# data dir related prod files
|
||||||
|
data/*.csv
|
||||||
|
|
||||||
|
# Ignore templ build artifacts
|
||||||
|
/bin/*
|
||||||
|
!bin/.gitkeep
|
||||||
|
|
||||||
|
# Ignore Unit Test result files
|
||||||
|
coverage.xml
|
||||||
|
testResults.xml
|
||||||
|
|
||||||
|
# Optional build state file
|
||||||
|
STATE.xml
|
||||||
|
42
.travis.yml
42
.travis.yml
@ -1,42 +0,0 @@
|
|||||||
|
|
||||||
language: csharp
|
|
||||||
dotnet: 2.2.101
|
|
||||||
mono: none
|
|
||||||
|
|
||||||
git:
|
|
||||||
depth: 1000
|
|
||||||
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
# Disable OSX bulds for now
|
|
||||||
# - osx
|
|
||||||
|
|
||||||
sudo: required
|
|
||||||
|
|
||||||
dist: xenial
|
|
||||||
osx_image: xcode8.1
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
fast_finish: true
|
|
||||||
|
|
||||||
|
|
||||||
#addons:
|
|
||||||
# artifacts:
|
|
||||||
# paths: ./dist/PowerShellGet.zip
|
|
||||||
|
|
||||||
|
|
||||||
install:
|
|
||||||
# Default 2.0.0 Ruby is buggy
|
|
||||||
# Default bundler version is buggy
|
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
|
||||||
rvm install ruby-2.3.3;
|
|
||||||
rvm --default use 2.3.3;
|
|
||||||
fi
|
|
||||||
- bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh)
|
|
||||||
- pushd tools
|
|
||||||
- chmod +x travis.sh
|
|
||||||
- popd
|
|
||||||
|
|
||||||
script:
|
|
||||||
- echo "TRAVIS_EVENT_TYPE value $TRAVIS_EVENT_TYPE"
|
|
||||||
- ./tools/travis.sh
|
|
42
.vscode/cSpell.json
vendored
42
.vscode/cSpell.json
vendored
@ -1,40 +1,22 @@
|
|||||||
// cSpell Settings
|
// cSpell Settings
|
||||||
{
|
{
|
||||||
// Version of the setting file. Always 0.1
|
// Version of the setting file. Always 0.1
|
||||||
"version": "0.1",
|
"version": "0.2",
|
||||||
// language - current active spelling language
|
// language - current active spelling language
|
||||||
"language": "en",
|
"language": "en,de,de-DE",
|
||||||
// words - list of words to be always considered correct
|
// words - list of words to be always considered correct
|
||||||
"words": [
|
"words": [],
|
||||||
"Cmdlet",
|
|
||||||
"Cmdlets",
|
|
||||||
"GUID",
|
|
||||||
"Hashtable",
|
|
||||||
"Httpclient",
|
|
||||||
"Multipart",
|
|
||||||
"NTFS",
|
|
||||||
"Params",
|
|
||||||
"Ponduit",
|
|
||||||
"Repo",
|
|
||||||
"Veyor",
|
|
||||||
"appveyor",
|
|
||||||
"callsign",
|
|
||||||
"choco",
|
|
||||||
"chocolatey",
|
|
||||||
"codecoverage",
|
|
||||||
"creds",
|
|
||||||
"formdata",
|
|
||||||
"googlemail",
|
|
||||||
"notlike",
|
|
||||||
"notmatch",
|
|
||||||
"powershellgallery",
|
|
||||||
"testresults",
|
|
||||||
"wildcards"
|
|
||||||
],
|
|
||||||
// flagWords - list of words to be always considered incorrect
|
// flagWords - list of words to be always considered incorrect
|
||||||
// This is useful for offensive words and common spelling errors.
|
// This is useful for offensive words and common spelling errors.
|
||||||
// For example "hte" should be "the"
|
// For example "hte" should be "the"
|
||||||
"flagWords": [
|
"flagWords": [],
|
||||||
"hte"
|
"dictionaryDefinitions": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"path": "./dictionaries/default.txt"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dictionaries": [
|
||||||
|
"default"
|
||||||
]
|
]
|
||||||
}
|
}
|
13
.vscode/extensions.json
vendored
Normal file
13
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"streetsidesoftware.code-spell-checker",
|
||||||
|
"streetsidesoftware.code-spell-checker-german",
|
||||||
|
"hediet.vscode-drawio",
|
||||||
|
"editorconfig.editorconfig",
|
||||||
|
"eamodio.gitlens",
|
||||||
|
"vscode-icons-team.vscode-icons",
|
||||||
|
"redhat.vscode-xml",
|
||||||
|
"redhat.vscode-yaml",
|
||||||
|
"ryanluker.vscode-coverage-gutters"
|
||||||
|
]
|
||||||
|
}
|
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -42,7 +42,7 @@
|
|||||||
"type": "PowerShell",
|
"type": "PowerShell",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "PowerShell Interactive Session",
|
"name": "PowerShell Interactive Session",
|
||||||
"cwd": ""
|
"cwd": "${workspaceRoot}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
31
.vscode/pwsh.code-snippets
vendored
Normal file
31
.vscode/pwsh.code-snippets
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
// Place your PowerShell-Module workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
|
||||||
|
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
|
||||||
|
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
|
||||||
|
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
|
||||||
|
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
|
||||||
|
// Placeholders with the same ids are connected.
|
||||||
|
// Example:
|
||||||
|
// "Print to console": {
|
||||||
|
// "scope": "javascript,typescript",
|
||||||
|
// "prefix": "log",
|
||||||
|
// "body": [
|
||||||
|
// "console.log('$1');",
|
||||||
|
// "$2"
|
||||||
|
// ],
|
||||||
|
// "description": "Log output to console"
|
||||||
|
// }
|
||||||
|
// PSScriptAnalyzder Rule Suppression
|
||||||
|
"Rule Suppression": {
|
||||||
|
"scope": "powershell",
|
||||||
|
"prefix": "[Diag",
|
||||||
|
"description": "Suppresses Scriptanalyzer Rules",
|
||||||
|
"body": [
|
||||||
|
"[Diagnostics.CodeAnalysis.SuppressMessageAttribute(",
|
||||||
|
" '${1|PSProvideCommentHelp,PSAvoidLongLines,PSAvoidUsingWriteHost,PSUseShouldProcessForStateChangingFunctions|}',",
|
||||||
|
" '',",
|
||||||
|
" Justification = '${justification}'",
|
||||||
|
")]"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
45
.vscode/settings.json
vendored
45
.vscode/settings.json
vendored
@ -1,34 +1,15 @@
|
|||||||
// Place your settings in this file to overwrite default and user settings.
|
|
||||||
{
|
{
|
||||||
// Set basic file related options:
|
|
||||||
"files.encoding": "utf8",
|
"files.encoding": "utf8",
|
||||||
"files.eol": "\r\n",
|
"files.eol": "auto",
|
||||||
"files.trimTrailingWhitespace": true,
|
"files.trimTrailingWhitespace": true,
|
||||||
"files.insertFinalNewline": true,
|
"files.insertFinalNewline": true,
|
||||||
// Formation and editor options
|
|
||||||
"editor.renderWhitespace": "boundary",
|
"editor.renderWhitespace": "boundary",
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"editor.formatOnType": true,
|
"editor.formatOnType": true,
|
||||||
"editor.rulers": [
|
"editor.rulers": [
|
||||||
116
|
116
|
||||||
],
|
],
|
||||||
// powershell general
|
"cSpell.enabled": true,
|
||||||
"powershell.startAutomatically": true,
|
|
||||||
"powershell.useX86Host": false,
|
|
||||||
"powershell.enableProfileLoading": true,
|
|
||||||
"powershell.scriptAnalysis.enable": true,
|
|
||||||
// powershell code Formatting
|
|
||||||
"powershell.codeFormatting.openBraceOnSameLine": true,
|
|
||||||
"powershell.codeFormatting.newLineAfterOpenBrace": true,
|
|
||||||
"powershell.codeFormatting.newLineAfterCloseBrace": true,
|
|
||||||
"powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
|
|
||||||
"powershell.codeFormatting.whitespaceBeforeOpenParen": true,
|
|
||||||
"powershell.codeFormatting.whitespaceAroundOperator": true,
|
|
||||||
"powershell.codeFormatting.whitespaceAfterSeparator": true,
|
|
||||||
"powershell.codeFormatting.ignoreOneLineBlock": true,
|
|
||||||
"powershell.codeFormatting.alignPropertyValuePairs": true,
|
|
||||||
"powershell.codeFormatting.preset": "Custom",
|
|
||||||
// cspell spellchecker options
|
|
||||||
"cSpell.enabledLanguageIds": [
|
"cSpell.enabledLanguageIds": [
|
||||||
"c",
|
"c",
|
||||||
"cpp",
|
"cpp",
|
||||||
@ -46,6 +27,26 @@
|
|||||||
"text",
|
"text",
|
||||||
"typescript",
|
"typescript",
|
||||||
"typescriptreact",
|
"typescriptreact",
|
||||||
|
"yaml",
|
||||||
"yml"
|
"yml"
|
||||||
]
|
],
|
||||||
|
"cSpell.language": "en,de,de-DE",
|
||||||
|
// powershell general
|
||||||
|
"powershell.startAutomatically": true,
|
||||||
|
"powershell.useX86Host": false,
|
||||||
|
"powershell.enableProfileLoading": true,
|
||||||
|
"powershell.scriptAnalysis.enable": true,
|
||||||
|
// powershell code Formatting
|
||||||
|
"powershell.codeFormatting.openBraceOnSameLine": true,
|
||||||
|
"powershell.codeFormatting.newLineAfterOpenBrace": true,
|
||||||
|
"powershell.codeFormatting.newLineAfterCloseBrace": true,
|
||||||
|
"powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
|
||||||
|
"powershell.codeFormatting.whitespaceBeforeOpenParen": true,
|
||||||
|
"powershell.codeFormatting.whitespaceAroundOperator": true,
|
||||||
|
"powershell.codeFormatting.whitespaceAfterSeparator": true,
|
||||||
|
"powershell.codeFormatting.ignoreOneLineBlock": true,
|
||||||
|
"powershell.codeFormatting.alignPropertyValuePairs": true,
|
||||||
|
"powershell.scriptAnalysis.settingsPath": "./tools/PSScriptAnalyzerSettings.psd1",
|
||||||
|
"coverage-gutters.showGutterCoverage": false,
|
||||||
|
"coverage-gutters.showLineCoverage": true
|
||||||
}
|
}
|
||||||
|
145
.vscode/tasks.json
vendored
145
.vscode/tasks.json
vendored
@ -1,56 +1,121 @@
|
|||||||
|
// A task runner that invokes Pester to run all Pester tests under the
|
||||||
|
// current workspace folder.
|
||||||
|
// NOTE: This Test task runner requires an updated version of Pester (>=4.0.3)
|
||||||
|
// in order for the problemMatcher to find failed test information (message, line, file).
|
||||||
|
// If you don't have that version, you can update Pester from the PowerShell Gallery
|
||||||
|
// with this command:
|
||||||
|
//
|
||||||
|
// PS C:\> Update-Module Pester
|
||||||
|
//
|
||||||
|
// If that gives an error like:
|
||||||
|
// "Module 'Pester' was not installed by using Install-Module, so it cannot be updated."
|
||||||
|
// then execute:
|
||||||
|
//
|
||||||
|
// PS C:\> Install-Module Pester -Scope CurrentUser -Force
|
||||||
|
//
|
||||||
|
// NOTE: The Clean, Build and Publish tasks require PSake. PSake can be installed
|
||||||
|
// from the PowerShell Gallery with this command:
|
||||||
|
//
|
||||||
|
// PS C:\> Install-Module PSake -Scope CurrentUser -Force
|
||||||
|
//
|
||||||
|
// Available variables which can be used inside of strings:
|
||||||
|
// ${workspaceFolder} the path of the workspace folder that contains the tasks.json file
|
||||||
|
// ${workspaceFolderBasename} the name of the workspace folder that contains the tasks.json file without any slashes (/)
|
||||||
|
// ${file} the current opened file
|
||||||
|
// ${relativeFile} the current opened file relative to the workspace folder containing the file
|
||||||
|
// ${fileBasename} the current opened file's basename
|
||||||
|
// ${fileBasenameNoExtension} the current opened file's basename without the extension
|
||||||
|
// ${fileDirname} the current opened file's dirname
|
||||||
|
// ${fileExtname} the current opened file's extension
|
||||||
|
// ${cwd} the task runner's current working directory on startup
|
||||||
|
// ${lineNumber} the current selected line number in the active file
|
||||||
{
|
{
|
||||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
||||||
// for the documentation about the tasks.json format
|
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
// Start PowerShell
|
//"windows": {
|
||||||
"windows": {
|
// "options": {
|
||||||
"command": "${env:windir}/System32/WindowsPowerShell/v1.0/powershell.exe",
|
// "shell": {
|
||||||
|
// // switch back to windows powershell 5.1
|
||||||
|
// // "executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
|
||||||
|
// "executable": "pwsh.exe",
|
||||||
|
// "args": [
|
||||||
|
// "-NoProfile",
|
||||||
|
// "-ExecutionPolicy",
|
||||||
|
// "Bypass",
|
||||||
|
// "-Command"
|
||||||
|
// ]
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//},
|
||||||
|
"linux": {
|
||||||
|
"options": {
|
||||||
|
"shell": {
|
||||||
|
"executable": "/usr/bin/pwsh",
|
||||||
"args": [
|
"args": [
|
||||||
"-NoProfile",
|
"-NoProfile",
|
||||||
"-ExecutionPolicy",
|
"-Command"
|
||||||
"Bypass"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linux": {
|
|
||||||
"command": "/usr/bin/powershell",
|
|
||||||
"args": [
|
|
||||||
"-NoProfile"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"osx": {
|
|
||||||
"command": "/usr/local/bin/powershell",
|
|
||||||
"args": [
|
|
||||||
"-NoProfile"
|
|
||||||
]
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
//"osx": {
|
||||||
|
// "options": {
|
||||||
|
// "shell": {
|
||||||
|
// "executable": "/usr/local/bin/pwsh",
|
||||||
|
// "args": [
|
||||||
|
// "-NoProfile",
|
||||||
|
// "-Command"
|
||||||
|
// ]
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//},
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"taskName": "Test",
|
"label": "DroneIO: Invoke-Linter",
|
||||||
"suppressTaskName": true,
|
"type": "shell",
|
||||||
"args": [
|
"command": [
|
||||||
"Write-Host 'Invoking Pester...'; $ProgressPreference = 'SilentlyContinue'; Invoke-Pester -Script ( Get-ChildItem -Path '.\\tests\\*.Tests.ps1' -Recurse | Sort-Object -Property Name ) -EnableExit $flase -PesterOption @{IncludeVSCodeMarker=$true};",
|
"Import-Module ./tools/DroneIO.psm1;",
|
||||||
"Invoke-Command { Write-Host 'Completed Test task in task runner.' }"
|
"Invoke-Linterq | Format-Table -AutoSize"
|
||||||
],
|
],
|
||||||
"problemMatcher": "$pester",
|
"group": "test",
|
||||||
"group": {
|
"problemMatcher": [
|
||||||
"kind": "test",
|
"$pester"
|
||||||
"isDefault": true
|
]
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"taskName": "DebugBuild",
|
"label": "DroneIO: Invoke-UnitTest",
|
||||||
"suppressTaskName": true,
|
"type": "shell",
|
||||||
"args": [
|
"command": [
|
||||||
"Write-Host 'Invoking Build...';",
|
"Remove-Item ./coverage.xml -ErrorAction 'SilentlyContinue';",
|
||||||
"Write-Host -Object 'Test previous builds.' -ForegroundColor Blue;",
|
"Remove-Item ./testResults.xml -ErrorAction 'SilentlyContinue';",
|
||||||
"If (Test-Path -Path '.\\bin\\PSCredentialStore.zip') { Remove-Item -Path '.\\bin\\PSCredentialStore.zip' -Verbose};",
|
"Import-Module ./tools/DroneIO.psm1;",
|
||||||
"Copy-Item -Path '.\\src\\' -Destination '.\\bin\\PSCredentialStore' -Recurse -Verbose -Force;",
|
"Invoke-UnitTest -CoverageFormat 'CoverageGutters' -Verbosity 'Diagnostic'"
|
||||||
"Compress-Archive -Path '.\\src\\*' -DestinationPath '.\\bin\\PSCredentialStore.zip' -Update -Verbose;"
|
|
||||||
],
|
],
|
||||||
"group": {
|
"group": "test",
|
||||||
"kind": "build",
|
"problemMatcher": [
|
||||||
"isDefault": true
|
"$pester"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Add dictionary item",
|
||||||
|
"type": "shell",
|
||||||
|
"command": [
|
||||||
|
"$DefaultFile = Get-ChildItem -Path './.vscode/dictionaries/default.txt';",
|
||||||
|
"$Content = Get-Content -Path $DefaultFile;",
|
||||||
|
"$Content += '${input:DictionaryItem}';",
|
||||||
|
"$Content = $Content | Sort-Object -Unique;",
|
||||||
|
"Set-Content -Value $Content -Path $DefaultFile"
|
||||||
|
],
|
||||||
|
"group": "none",
|
||||||
|
"problemMatcher": [
|
||||||
|
"$pester"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"id": "DictionaryItem",
|
||||||
|
"type": "promptString",
|
||||||
|
"description": "Input for dictionary file default.txt"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
41
CHANGELOG.md
Normal file
41
CHANGELOG.md
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
<!-- insertMark -->
|
||||||
|
## [v1.1.1](https://gitea.ocram85.com/OCram85/PSCredentialStore/releases/tag/v1.1.1) - 2022-10-10
|
||||||
|
|
||||||
|
* 📦 META
|
||||||
|
* Adds changelog config for gitea changelog cli tool (#77)
|
||||||
|
* 🐛 BUGFIXES
|
||||||
|
* Fix Set-CredentialStoreItem (#76)
|
||||||
|
* Fix optional module dependencies (#75)
|
||||||
|
|
||||||
|
### Contributors
|
||||||
|
|
||||||
|
|
||||||
|
* [@OCram85](https://gitea.ocram85.com/OCram85)
|
||||||
|
* [@pinguinfuss](https://gitea.ocram85.com/pinguinfuss)
|
||||||
|
|
||||||
|
## `v1.1.0`
|
||||||
|
|
||||||
|
- (3d4f53d) adds pinguinfuss contributed fix (#73)
|
||||||
|
- (6fce8d6) Updates libressl files (#71)
|
||||||
|
- (ddb85d9) addChangelog (#70)
|
||||||
|
- (5bdb383) updates Readme (#69)
|
||||||
|
- (a95ba31) remove optional depenency helper (#68)
|
||||||
|
- (1e7dd78) adds CiscoUCSCentral connection type (#67)
|
||||||
|
- (b76668c) fix Test-CredentialStoreItem return (#66)
|
||||||
|
- (ae62ccc) switch to GNU AGPLv3 license (#64)
|
||||||
|
- (a66e824) adds community contribution for CiscoUCS connection fix (#63)
|
||||||
|
- (3d90d91) fix lint (PSScriptAnalyzer) issues (#62)
|
||||||
|
- (d0b7e53) adds DroneHelper (#61)
|
||||||
|
- (d4b00a5) Migrates to Pester5+ tests (#59)
|
||||||
|
- (e340466) update references (#60)
|
||||||
|
- (88743e9) fix pester verbosity config (#58)
|
||||||
|
- (c31ee79) Update issue templates (#57)
|
||||||
|
- (c45490a) Update issue templates (#56)
|
||||||
|
- (4abfec5) adds PR template (#55)
|
||||||
|
- (7708df9) Update pwsh style to latest community standards (#52)
|
||||||
|
|
||||||
|
## `v1.0.542`
|
||||||
|
|
||||||
|
- 🧙 pre migrated Gitea version
|
248
LICENSE
248
LICENSE
@ -1,21 +1,235 @@
|
|||||||
MIT License
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
Copyright (c) 2017 Marco Blessing
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
Preamble
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.
|
||||||
|
165
README.md
165
README.md
@ -1,78 +1,153 @@
|
|||||||
[![AppVeyor branch](https://img.shields.io/appveyor/ci/OCram85/PSCredentialStore/master.svg?style=plastic "Master Banch Build Status")](https://ci.appveyor.com/project/OCram85/pscredentialstore/branch/master)
|
<p align="right">
|
||||||
[![AppVeyor tests branch](https://img.shields.io/appveyor/tests/OCram85/PSCredentialStore/master.svg?style=plastic "Pester Tests Results")](https://ci.appveyor.com/project/OCram85/pscredentialstore/branch/master/tests)
|
<img src="http://forthebadge.com/images/badges/built-with-love.svg">
|
||||||
[![Coveralls github](https://img.shields.io/coveralls/github/OCram85/PSCredentialStore.svg?style=plastic "Coveralls.io Coverage Report")](https://coveralls.io/github/OCram85/PSCredentialStore?branch=master)
|
<img src="http://forthebadge.com/images/badges/for-you.svg">
|
||||||
[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/PSCredentialStore.svg?style=plastic "PowershellGallery Published Version")](https://www.powershellgallery.com/packages/PSCredentialStore)
|
</p>
|
||||||
[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/PSCredentialStore.svg?style=plastic "PowershellGallery Downloads")](https://www.powershellgallery.com/packages/PSCredentialStore)
|
|
||||||
|
|
||||||
![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)
|
<p align="center">
|
||||||
![forthebadge](http://forthebadge.com/images/badges/for-you.svg)
|
<a href="https://gitea.ocram85.com/OCram85/PSCredentialStore/">
|
||||||
|
<img
|
||||||
|
src="https://gitea.ocram85.com/OCram85/PSCredentialStore/raw/branch/master/assets/social-logo.png"
|
||||||
|
alt="PSCredentialStore"
|
||||||
|
>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
General
|
<h1 align="center">
|
||||||
=======
|
PSCredentialStore
|
||||||
|
</h1>
|
||||||
|
|
||||||
The PSCredentialStore is a simple credential manager for PSCredentials. It stores PSCredentials in a simple json
|
<p align="center">
|
||||||
file. You can choose between a private and shared credential store. The private one exists in your profile and can
|
🔐 A simple cross-platform credential manager for PSCredential objects.
|
||||||
ony accessed by your account on the same machine. The shared store enables you to use different credentials for your
|
</p>
|
||||||
scripts without exposing them as plain text.
|
|
||||||
|
|
||||||
**The shared store isn't 100% secure and I don't recommend using it in production!**
|
<p align="center">
|
||||||
|
<a href="https://drone.ocram85.com/OCram85/PSCredentialStore">
|
||||||
|
<img
|
||||||
|
src="https://drone.ocram85.com/api/badges/OCram85/PSCredentialStore/status.svg"
|
||||||
|
alt="Master Branch Build Status"
|
||||||
|
>
|
||||||
|
</a>
|
||||||
|
<!-- CodeCove disabled for self hosting git
|
||||||
|
<a href="https://codecov.io/gh/OCram85/PSCredentialStore">
|
||||||
|
<img src="https://codecov.io/gh/OCram85/PSCredentialStore/branch/master/graph/badge.svg" alt="CodeCov">
|
||||||
|
</a>
|
||||||
|
-->
|
||||||
|
<a href="https://www.powershellgallery.com/packages/PSCredentialStore">
|
||||||
|
<img
|
||||||
|
src="https://img.shields.io/powershellgallery/v/PSCredentialStore.svg?style=plastic"
|
||||||
|
alt="PowershellGallery Published Version"
|
||||||
|
>
|
||||||
|
</a>
|
||||||
|
<a href="https://www.powershellgallery.com/packages/PSCredentialStore">
|
||||||
|
<img
|
||||||
|
src="https://img.shields.io/powershellgallery/vpre/PSCredentialStore.svg?label=latest%20preview&style=plastic"
|
||||||
|
>
|
||||||
|
</a>
|
||||||
|
<a href="https://www.powershellgallery.com/packages/PSCredentialStore">
|
||||||
|
<img
|
||||||
|
src="https://img.shields.io/powershellgallery/dt/PSCredentialStore.svg?style=plastic"
|
||||||
|
>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
## :key: General
|
||||||
|
|
||||||
|
The PSCredentialStore is a simple credential manager for `PSCredential` objects. It stores PSCredentials in a simple
|
||||||
|
json file. You can choose between a private and shared credential store. The private one exists in your profile and
|
||||||
|
can ony accessed by your account on the same machine. The shared store enables you to use different credentials for
|
||||||
|
your scripts without exposing them as plain text.
|
||||||
|
|
||||||
PSCredentialStore was developed to simplify the delegation of complex powershell scripts. In this case you often
|
PSCredentialStore was developed to simplify the delegation of complex powershell scripts. In this case you often
|
||||||
need to store credentials for non interactive usage like in scheduled tasks.
|
need to store credentials for non interactive usage like in scheduled tasks.
|
||||||
|
|
||||||
For more details read the [about_PSCredentialStore](/docs/about_PSCredentialStore.md) page on github or via CLI with
|
Starting with version `1.0.0` PSCredential uses Pfx certificates fo encryption. You can use Pfx certificate files
|
||||||
|
or certificates stored in the certificate store.
|
||||||
|
|
||||||
|
For more details read the [about_PSCredentialStore](docs/about_PSCredentialStore.md) page on Gitea or via CLI with
|
||||||
`Get-Help about_PSCredentialStore`.
|
`Get-Help about_PSCredentialStore`.
|
||||||
|
|
||||||
:exclamation: Upcoming Changes :exclamation:
|
You can find the full [reference](docs/Readme.md) in the */docs/* path as well.
|
||||||
================
|
|
||||||
|
|
||||||
The will be some breaking changes starting with the `0.5.0.xxx`:
|
## :vulcan_salute: Requirements
|
||||||
|
|
||||||
- **PSCredentialStore will use PFX certificates to encrypt your credentials.**
|
- PowerShell >= `5.1`
|
||||||
- This replaces the the current encryption methods and you need to recreate or upgrade your pre existing stores.
|
- .NET Framework >= `4.6` or .NET Core >= `1.0`
|
||||||
- The changes allows the PSCredentialStore module to support the PowerShell `Core` editions.
|
|
||||||
- Yes this means, you can use the module on any PowerShell 6 supported linux distribution.
|
|
||||||
- It's also possible to create a shared credential store and transfer it onto a another platform like:
|
|
||||||
`Windows -- to --> Linux` and vice versa.
|
|
||||||
- Automatically creates self signed certificate with 2048 bits RSA keys for encryption.
|
|
||||||
|
|
||||||
Installation
|
## :bomb: About Security
|
||||||
============
|
|
||||||
|
|
||||||
PowerShellGallery.com (Recommended Way)
|
> This section explains some security topics and the design decisions we made to balance the usage and security needs.
|
||||||
---------------------------------------
|
|
||||||
|
To be able to delegate `PSCredentials` objects we can't exclusively rely on the `SecureString` cmdlets. You can't
|
||||||
|
decrypt and reuse such credentials from a different user account or even machine. This is caused by automatically
|
||||||
|
generated encryption key, which is used create a `Secure String` based encrypted string.
|
||||||
|
|
||||||
|
In order to delegate a password, while still using the underlying security framework, we have to provide a custom
|
||||||
|
encryption key. This leads to the fact, that everyone who has access to the key could encrypt or decrypt your data.
|
||||||
|
|
||||||
|
So we decided to use the public and private keys from valid certificates as part of the custom encryption keys to
|
||||||
|
encrypt your data.
|
||||||
|
|
||||||
|
This means clearly: Everyone who has access to the `CredentialStore` needs also access to the certificate file to
|
||||||
|
work with it.
|
||||||
|
|
||||||
|
Keep in mind you need to secure the access with your NTFS file permissions to avoid unwanted usage. Another option
|
||||||
|
is to import the certificate into your certification vaults of you operating system. In this case you can grand the
|
||||||
|
permission to the certificates itself.
|
||||||
|
|
||||||
|
Here is a brief hierarchy description for the certificate lookup order: *(First match wins)*
|
||||||
|
|
||||||
|
| CredentialStore Type | Certificate Location |
|
||||||
|
| -------------------- | ---------------------- |
|
||||||
|
| Private | `CurrentUser`\\`My` |
|
||||||
|
| Shared (Windows) | `CurrentUser`\\`My` |
|
||||||
|
| | `LocalMachine`\\`Root` |
|
||||||
|
| Shared (Linux) | `LocalMachine`\\`My` |
|
||||||
|
| | `LocalMachine`\\`Root` |
|
||||||
|
|
||||||
|
## :hammer_and_wrench: Installation
|
||||||
|
|
||||||
|
### :artificial_satellite: PowerShellGallery.com (Recommended Way)
|
||||||
|
|
||||||
* Make sure you use PowerShell 5.1 or higher with `$PSVersionTable`.
|
* Make sure you use PowerShell 5.1 or higher with `$PSVersionTable`.
|
||||||
* Use the builtin PackageManagement and install with: `Import-Module PowerShellGet; Install-Module 'PSCredentialStore' -Repository 'PSGallery'`
|
* Use the builtin PackageManagement + PowerShellGet module and install PSCredentialStore with: `Import-Module PowerShellGet; Install-Module 'PSCredentialStore' -Repository 'PSGallery'`
|
||||||
* Additionally use the `-AllowPrerelease` switch until we publish the final release!
|
* Additionally use the `-AllowPrerelease` switch until we publish the final release!
|
||||||
* Done. Start exploring the Module with `Import-Module PSCredentialStore ; Get-Command -Module PSCredentialStore`
|
* Done. Start exploring the Module with `Import-Module PSCredentialStore; Get-Command -Module PSCredentialStore`
|
||||||
|
|
||||||
Manual Way
|
### :building_construction: Manual Way
|
||||||
----------
|
|
||||||
|
|
||||||
* Take a look at the [Latest Release](https://github.com/OCram85/PSCredentialStore/releases/latest) page.
|
* Take a look at the [Latest Release](https://gitea.ocram85.com/OCram85/PSCredentialStore/releases/latest) page.
|
||||||
* Download the `PSCredentialStore.zip`.
|
* Download the `PSCredentialStore.zip`.
|
||||||
* Unpack the zip file and put it in your Powershell module path.
|
* Unpack the zip file and put it in your Powershell module path.
|
||||||
* Don't forget to change the NTFS permission flag in the context menu.
|
* Don't forget to change the NTFS permission flag in the context menu.
|
||||||
* Start with `Import-Module PSCredentialStore`
|
* Start with `Import-Module PSCredentialStore`
|
||||||
|
|
||||||
Quick Start
|
### :sparkles: Quick Start
|
||||||
-----------
|
|
||||||
|
**1.** First we need a blank credential store. You can decide between a *private* or *shared* one.
|
||||||
|
|
||||||
|
> :bulb: Note: The private credential store can only be accessed with your profile on the machine you created it.
|
||||||
|
|
||||||
|
Starting with version `1.0.0` you can decide the storage type of your fresh created certificate. As default
|
||||||
|
PSCredentialStore creates a new pfx certificate file beside the credential store itself. Optionally you can provide
|
||||||
|
the parameter `-UseCertStore`. This imports the new certificate in the user or machine certificate store as well.
|
||||||
|
|
||||||
**1.** First we need a blank credential store. You can decide between a *private* or *shared* store. The private
|
|
||||||
Credential Store can only be accessed with your profile on the machine you created it.
|
|
||||||
```powershell
|
```powershell
|
||||||
# Private credential store
|
# Private credential store
|
||||||
New-CredentialStore
|
New-CredentialStore
|
||||||
|
|
||||||
# Shared credential rtore
|
# Private credential store with certificate store usage
|
||||||
|
New-CredentialStore -UseCertStore
|
||||||
|
|
||||||
|
# Shared credential store
|
||||||
New-CredentialStore -Shared
|
New-CredentialStore -Shared
|
||||||
|
|
||||||
#Shared credential store in custom Location
|
# Shared credential store in custom location
|
||||||
New-CredentialStore -Shared -Path 'C:\CredentialStore.json'
|
New-CredentialStore -Shared -Path 'C:\CredentialStore.json'
|
||||||
```
|
```
|
||||||
|
|
||||||
**2.** Now you can manage your credential store items:
|
**2.** Now you can manage your credential store items:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# This will prompt for credentials and stores it in a private store
|
# This will prompt for credentials and stores it in a private store
|
||||||
New-CredentialStoreItem -RemoteHost 'dc01.myside.local' -Identifier 'AD'
|
New-CredentialStoreItem -RemoteHost 'dc01.myside.local' -Identifier 'AD'
|
||||||
@ -83,7 +158,7 @@ Invoke-Command -ComputerName 'dc01.myside.local' -Credential $DCCreds -ScripBloc
|
|||||||
```
|
```
|
||||||
|
|
||||||
The credential store contains also a simple function to establish a connection with several systems or protocols.
|
The credential store contains also a simple function to establish a connection with several systems or protocols.
|
||||||
If you have already installed the underlying framework / modules, you can connect these endpoints:
|
If you have already installed the underlying framework / modules, you can connect to these endpoint types:
|
||||||
|
|
||||||
* **CiscoUcs** - Establish a connection to a Cisco UCS fabric interconnect.
|
* **CiscoUcs** - Establish a connection to a Cisco UCS fabric interconnect.
|
||||||
* Required Modules: [`Cisco.UCS.Core`, `Cisco.UCSManager`](https://software.cisco.com/download/release.html?i=!y&mdfid=286305108&softwareid=284574017&release=2.1.1)
|
* Required Modules: [`Cisco.UCS.Core`, `Cisco.UCSManager`](https://software.cisco.com/download/release.html?i=!y&mdfid=286305108&softwareid=284574017&release=2.1.1)
|
||||||
@ -110,14 +185,16 @@ Connect-To -RemoteHost "ftp.myside.local" -Type FTP
|
|||||||
Connect-To -RemoteHost "fas.myside.local" -Type NetAppFAS
|
Connect-To -RemoteHost "fas.myside.local" -Type NetAppFAS
|
||||||
Connect-To -RemoteHost "esx01.myside.local" -Type VMware
|
Connect-To -RemoteHost "esx01.myside.local" -Type VMware
|
||||||
Connect-To -RemoteHost "vcr.myside.local" -Type CisServer
|
Connect-To -RemoteHost "vcr.myside.local" -Type CisServer
|
||||||
|
Connect-To -RemoteHost "exchange1.myside.local" -Type ExchangeHTTP
|
||||||
|
Connect-To -RemoteHost "exchange1.myside.local" -Type ExchangeHTTPS
|
||||||
|
Connect-To -RemoteHost "ubuntu.myside.local" -Type SCP
|
||||||
```
|
```
|
||||||
|
|
||||||
Credits
|
### :pushpin: Credits
|
||||||
-------
|
|
||||||
|
|
||||||
A huge thanks to all the people who helped with their projects and indirect contributions which made this possible!
|
A huge thanks to all the people who helped with their projects and indirect contributions which made this possible!
|
||||||
|
|
||||||
- This module is inspired by the awesome work of @dlwyatt with articles like these:
|
- This module is inspired by the awesome work of Dave Wyatt ([@dlwyatt](https://github.com/dlwyatt)) with articles like these:
|
||||||
- https://powershell.org/2013/11/24/saving-passwords-and-preventing-other-processes-from-decrypting-them/
|
- https://powershell.org/2013/11/24/saving-passwords-and-preventing-other-processes-from-decrypting-them/
|
||||||
- https://powershell.org/2014/02/01/revisited-powershell-and-encryption/
|
- https://powershell.org/2014/02/01/revisited-powershell-and-encryption/
|
||||||
- The awesome people from [LibreSSL](http://www.libressl.org/) which publishes the [portable openssl/libressl binaries](https://github.com/libressl-portable/portable)!
|
- The awesome people from [LibreSSL](http://www.libressl.org/) which publishes the [portable openssl/libressl binaries](https://github.com/libressl-portable/portable)!
|
||||||
|
76
appveyor.yml
76
appveyor.yml
@ -1,76 +0,0 @@
|
|||||||
# release version:
|
|
||||||
#version: 0.5.0.{build}
|
|
||||||
|
|
||||||
# pre release version:
|
|
||||||
version: 0.5.{build}
|
|
||||||
|
|
||||||
#branches:
|
|
||||||
# only:
|
|
||||||
# - master
|
|
||||||
# - dev
|
|
||||||
# - debug
|
|
||||||
|
|
||||||
skip_tags: true
|
|
||||||
|
|
||||||
#image: WMF 5
|
|
||||||
# Test ne build image:
|
|
||||||
image: Visual Studio 2017
|
|
||||||
|
|
||||||
# Install pester module and init the Appveyor support.
|
|
||||||
|
|
||||||
# Enable RDP connection for debugging
|
|
||||||
#init:
|
|
||||||
# - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
|
||||||
|
|
||||||
install:
|
|
||||||
- ps: Import-Module .\tools\AppVeyor.psm1
|
|
||||||
- ps: Invoke-InstallDependencies
|
|
||||||
|
|
||||||
environment:
|
|
||||||
NuGetToken:
|
|
||||||
secure: 835qfZIkC9mE7QhkYfOZVAdR8rZhPvxG8BO4CbeaelRQOhlqmaSr8G1DWRJzZ/bS
|
|
||||||
CoverallsToken:
|
|
||||||
secure: eTjWqHL48MBr8wp1rSgLrXHdtpfDV/uClacP3svlWJfCvn/zVokpuaMnWM5RoyIY
|
|
||||||
|
|
||||||
build: false
|
|
||||||
|
|
||||||
before_build:
|
|
||||||
- ps: Invoke-AppVeyorBumpVersion
|
|
||||||
|
|
||||||
build_script:
|
|
||||||
- ps: Invoke-AppVeyorBuild
|
|
||||||
|
|
||||||
test_script:
|
|
||||||
- ps: |
|
|
||||||
$CodeCoverage = Invoke-AppVeyorTests
|
|
||||||
if ($null -ne $Env:CoverallsToken) {
|
|
||||||
Invoke-CoverageReport -PesterCoverageReport $CodeCoverage
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-Warning "No CoverallsToken found. This build seems to be triggered by a PR. Skipping this step..."
|
|
||||||
}
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
#- provider: GitHub
|
|
||||||
# auth_token:
|
|
||||||
# secure: M+bBX5/nKdJB0eViP7xtrLVTwf3vGDUA9N2MMprZp2i+9ZR3CBVcJnSzJWUmalhB
|
|
||||||
# artifact: PSCredentialStore.zip # upload all NuGet packages to release assets
|
|
||||||
# draft: true
|
|
||||||
# prerelease: true
|
|
||||||
# on:
|
|
||||||
# branch: dev
|
|
||||||
- provider: GitHub
|
|
||||||
auth_token:
|
|
||||||
secure: M+bBX5/nKdJB0eViP7xtrLVTwf3vGDUA9N2MMprZp2i+9ZR3CBVcJnSzJWUmalhB
|
|
||||||
artifact: PSCredentialStore.zip # upload all NuGet packages to release assets
|
|
||||||
draft: false
|
|
||||||
prerelease: true
|
|
||||||
on:
|
|
||||||
branch: master # build release on master branch changes
|
|
||||||
|
|
||||||
after_deploy:
|
|
||||||
- ps: Invoke-AppVeyorPSGallery -OnBranch 'master'
|
|
||||||
|
|
||||||
# Pause build until `lock` on desktop is deleted.
|
|
||||||
#on_finish:
|
|
||||||
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
|
BIN
assets/colorscheme.png
Normal file
BIN
assets/colorscheme.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
assets/social-logo.png
Normal file
BIN
assets/social-logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
0
build/.gitkeep
Normal file
0
build/.gitkeep
Normal file
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
external help file: PSCredentialStore-help.xml
|
external help file: ModuleRoot-help.xml
|
||||||
Module Name: PSCredentialStore
|
Module Name: PSCredentialStore
|
||||||
online version: https://github.com/OCram85/PSCredentialStore
|
online version:
|
||||||
schema: 2.0.0
|
schema: 2.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -14,14 +14,14 @@ Connects to the given host using the stored CredentialStoreItem.
|
|||||||
|
|
||||||
### Private (Default)
|
### Private (Default)
|
||||||
```
|
```
|
||||||
Connect-To -RemoteHost <String> [-Identifier <String>] -Type <String> [-Credentials <PSCredential>]
|
Connect-To -RemoteHost <String> [-Identifier <String>] -Type <String> [-Credentials <PSCredential>] [-PassThru]
|
||||||
[<CommonParameters>]
|
[<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Shared
|
### Shared
|
||||||
```
|
```
|
||||||
Connect-To -RemoteHost <String> [-Identifier <String>] -Type <String> [-Credentials <PSCredential>]
|
Connect-To -RemoteHost <String> [-Identifier <String>] -Type <String> [-Credentials <PSCredential>] [-Shared]
|
||||||
[-Path <String>] [-Shared] [<CommonParameters>]
|
[-Path <String>] [-PassThru] [<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
@ -36,31 +36,36 @@ Connect-To -RemoteHost "ucs.myside.local" -Type CiscoUcs
|
|||||||
|
|
||||||
### EXAMPLE 2
|
### EXAMPLE 2
|
||||||
```
|
```
|
||||||
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
|
Connect-To -RemoteHost "ucscentral.myside.local" -Type 'CiscoUcsCentral'
|
||||||
```
|
```
|
||||||
|
|
||||||
### EXAMPLE 3
|
### EXAMPLE 3
|
||||||
```
|
```
|
||||||
Connect-To -RemoteHost "fas.myside.local" -Type NetAppFAS
|
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
|
||||||
```
|
```
|
||||||
|
|
||||||
### EXAMPLE 4
|
### EXAMPLE 4
|
||||||
```
|
```
|
||||||
Connect-To -RemoteHost "esx01.myside.local" -Type VMware
|
Connect-To -RemoteHost "fas.myside.local" -Type NetAppFAS
|
||||||
```
|
```
|
||||||
|
|
||||||
### EXAMPLE 5
|
### EXAMPLE 5
|
||||||
```
|
```
|
||||||
Connect-To -RemoteHost "vCenter.myside.local" -Type CisServer
|
Connect-To -RemoteHost "esx01.myside.local" -Type VMware
|
||||||
```
|
```
|
||||||
|
|
||||||
### EXAMPLE 6
|
### EXAMPLE 6
|
||||||
```
|
```
|
||||||
Connect-To -RemoteHost "exchange01.myside.local" -Type ExchangeHTTP
|
Connect-To -RemoteHost "vCenter.myside.local" -Type CisServer
|
||||||
```
|
```
|
||||||
|
|
||||||
### EXAMPLE 7
|
### EXAMPLE 7
|
||||||
```
|
```
|
||||||
|
Connect-To -RemoteHost "exchange01.myside.local" -Type ExchangeHTTP
|
||||||
|
```
|
||||||
|
|
||||||
|
### EXAMPLE 8
|
||||||
|
```
|
||||||
Connect-To -RemoteHost "exchange01.myside.local" -Type ExchangeHTTPS
|
Connect-To -RemoteHost "exchange01.myside.local" -Type ExchangeHTTPS
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -102,6 +107,21 @@ Accept pipeline input: False
|
|||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### -PassThru
|
||||||
|
Returns the value from the underlying connection type function.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: SwitchParameter
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: Named
|
||||||
|
Default value: False
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
### -Path
|
### -Path
|
||||||
Define a custom path to a shared CredentialStore.
|
Define a custom path to a shared CredentialStore.
|
||||||
|
|
||||||
@ -112,7 +132,7 @@ Aliases:
|
|||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
Default value: "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
@ -142,7 +162,7 @@ Type: SwitchParameter
|
|||||||
Parameter Sets: Shared
|
Parameter Sets: Shared
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: False
|
Required: True
|
||||||
Position: Named
|
Position: Named
|
||||||
Default value: False
|
Default value: False
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
@ -152,7 +172,16 @@ Accept wildcard characters: False
|
|||||||
### -Type
|
### -Type
|
||||||
Specify the host type of the target.
|
Specify the host type of the target.
|
||||||
Currently implemented targets are: Possible connection values are:
|
Currently implemented targets are: Possible connection values are:
|
||||||
CiscoUcs, FTP, NetAppFAS, VMware, CisServer, ExchangeHTTP, ExchangeHTTPS, SCP.
|
|
||||||
|
- CiscoUcs
|
||||||
|
- CiscoUcsCentral
|
||||||
|
- CisServer
|
||||||
|
- ExchangeHTTP
|
||||||
|
- ExchangeHTTPS
|
||||||
|
- FTP
|
||||||
|
- NetAppFAS
|
||||||
|
- SCP
|
||||||
|
- VMware
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: String
|
||||||
@ -167,22 +196,14 @@ Accept wildcard characters: False
|
|||||||
```
|
```
|
||||||
|
|
||||||
### CommonParameters
|
### CommonParameters
|
||||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
## INPUTS
|
## INPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## OUTPUTS
|
## OUTPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## NOTES
|
## NOTES
|
||||||
File Name : Connect-To.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
|
|
||||||
## RELATED LINKS
|
## RELATED LINKS
|
||||||
|
|
||||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
external help file: PSCredentialStore-help.xml
|
external help file: ModuleRoot-help.xml
|
||||||
Module Name: PSCredentialStore
|
Module Name: PSCredentialStore
|
||||||
online version: https://github.com/OCram85/PSCredentialStore
|
online version:
|
||||||
schema: 2.0.0
|
schema: 2.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -95,8 +95,17 @@ Accept wildcard characters: False
|
|||||||
|
|
||||||
### -Type
|
### -Type
|
||||||
Specify the host type of the target.
|
Specify the host type of the target.
|
||||||
Currently implemented targets are: CiscoUcs, FTP, NetAppFAS, VMware,
|
Currently implemented targets are:
|
||||||
CisServer, ExchangeHTTP, ExchangeHTTPS, SCP.
|
|
||||||
|
- CiscoUcs
|
||||||
|
- CiscoUcsCentral
|
||||||
|
- FTP
|
||||||
|
- NetAppFAS
|
||||||
|
- VMware
|
||||||
|
- CisServer
|
||||||
|
- ExchangeHTTP
|
||||||
|
- ExchangeHTTPS
|
||||||
|
- SCP
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: String
|
||||||
@ -111,22 +120,14 @@ Accept wildcard characters: False
|
|||||||
```
|
```
|
||||||
|
|
||||||
### CommonParameters
|
### CommonParameters
|
||||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
## INPUTS
|
## INPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## OUTPUTS
|
## OUTPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## NOTES
|
## NOTES
|
||||||
File Name : Disconnect-From.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
|
|
||||||
## RELATED LINKS
|
## RELATED LINKS
|
||||||
|
|
||||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
|
||||||
|
|
||||||
|
72
docs/Get-CSCertificate.md
Normal file
72
docs/Get-CSCertificate.md
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
---
|
||||||
|
external help file: ModuleRoot-help.xml
|
||||||
|
Module Name: PSCredentialStore
|
||||||
|
online version:
|
||||||
|
schema: 2.0.0
|
||||||
|
---
|
||||||
|
|
||||||
|
# Get-CSCertificate
|
||||||
|
|
||||||
|
## SYNOPSIS
|
||||||
|
Returns the current used valid PfX certificate.
|
||||||
|
|
||||||
|
## SYNTAX
|
||||||
|
|
||||||
|
```
|
||||||
|
Get-CSCertificate [-Type] <String> [-Thumbprint] <String> [<CommonParameters>]
|
||||||
|
```
|
||||||
|
|
||||||
|
## DESCRIPTION
|
||||||
|
Use this function to get the available pfx certificate respecting the config hierarchy.
|
||||||
|
|
||||||
|
## EXAMPLES
|
||||||
|
|
||||||
|
### EXAMPLE 1
|
||||||
|
```
|
||||||
|
Get-CSCertificate -Type 'Shared' -Thumbprint '12334456'
|
||||||
|
```
|
||||||
|
|
||||||
|
## PARAMETERS
|
||||||
|
|
||||||
|
### -Thumbprint
|
||||||
|
Provide the credentials thumbprint for the search.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: 2
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -Type
|
||||||
|
Select the current credential store type.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: 1
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### CommonParameters
|
||||||
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
|
## INPUTS
|
||||||
|
|
||||||
|
### [None]
|
||||||
|
## OUTPUTS
|
||||||
|
|
||||||
|
### [System.Security.Cryptography.X509Certificates.X509Certificate2]
|
||||||
|
## NOTES
|
||||||
|
|
||||||
|
## RELATED LINKS
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
external help file: PSCredentialStore-help.xml
|
external help file: ModuleRoot-help.xml
|
||||||
Module Name: PSCredentialStore
|
Module Name: PSCredentialStore
|
||||||
online version: https://github.com/OCram85/PSCredentialStore
|
online version:
|
||||||
schema: 2.0.0
|
schema: 2.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ Aliases:
|
|||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
Default value: "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
@ -71,24 +71,14 @@ Accept wildcard characters: False
|
|||||||
```
|
```
|
||||||
|
|
||||||
### CommonParameters
|
### CommonParameters
|
||||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
## INPUTS
|
## INPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## OUTPUTS
|
## OUTPUTS
|
||||||
|
|
||||||
### [PSObject] Returns the credential store content as PSObject.
|
### [PSObject] Returns the credential store content as PSObject.
|
||||||
|
|
||||||
## NOTES
|
## NOTES
|
||||||
\`\`\`
|
|
||||||
File Name : Get-CredentialStore.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
## RELATED LINKS
|
## RELATED LINKS
|
||||||
|
|
||||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
external help file: PSCredentialStore-help.xml
|
external help file: ModuleRoot-help.xml
|
||||||
Module Name: PSCredentialStore
|
Module Name: PSCredentialStore
|
||||||
online version: https://github.com/OCram85/PSCredentialStore
|
online version:
|
||||||
schema: 2.0.0
|
schema: 2.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ Aliases:
|
|||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
Default value: "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
@ -101,24 +101,14 @@ Accept wildcard characters: False
|
|||||||
```
|
```
|
||||||
|
|
||||||
### CommonParameters
|
### CommonParameters
|
||||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
## INPUTS
|
## INPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## OUTPUTS
|
## OUTPUTS
|
||||||
|
|
||||||
### [System.Management.Automation.PSCredential]
|
### [System.Management.Automation.PSCredential]
|
||||||
|
|
||||||
## NOTES
|
## NOTES
|
||||||
\`\`\`
|
|
||||||
File Name : Get-CredentialStoreItem.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
## RELATED LINKS
|
## RELATED LINKS
|
||||||
|
|
||||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
|
||||||
|
|
||||||
|
73
docs/Import-CSCertificate.md
Normal file
73
docs/Import-CSCertificate.md
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
---
|
||||||
|
external help file: ModuleRoot-help.xml
|
||||||
|
Module Name: PSCredentialStore
|
||||||
|
online version:
|
||||||
|
schema: 2.0.0
|
||||||
|
---
|
||||||
|
|
||||||
|
# Import-CSCertificate
|
||||||
|
|
||||||
|
## SYNOPSIS
|
||||||
|
Imports a linked certificate to the valid store location.
|
||||||
|
|
||||||
|
## SYNTAX
|
||||||
|
|
||||||
|
```
|
||||||
|
Import-CSCertificate [-Type] <String> [-Path] <FileInfo> [<CommonParameters>]
|
||||||
|
```
|
||||||
|
|
||||||
|
## DESCRIPTION
|
||||||
|
Import-CSCertificate takes a pfx certificate file and imports it to the supposed certificate store for
|
||||||
|
private and shared credential stores.
|
||||||
|
|
||||||
|
## EXAMPLES
|
||||||
|
|
||||||
|
### EXAMPLE 1
|
||||||
|
```
|
||||||
|
Import-CSCertificate -Type 'Private' -Path (Join-Path -Path $Env:APPDATA -ChildItem 'PfxCertificate.pfx')
|
||||||
|
```
|
||||||
|
|
||||||
|
## PARAMETERS
|
||||||
|
|
||||||
|
### -Path
|
||||||
|
Provide a valid path to pfx certificate file.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: FileInfo
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: 2
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -Type
|
||||||
|
Select between the a private and shared credential store.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: 1
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### CommonParameters
|
||||||
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
|
## INPUTS
|
||||||
|
|
||||||
|
### [None]
|
||||||
|
## OUTPUTS
|
||||||
|
|
||||||
|
### [None]
|
||||||
|
## NOTES
|
||||||
|
|
||||||
|
## RELATED LINKS
|
156
docs/New-CSCertAttribute.md
Normal file
156
docs/New-CSCertAttribute.md
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
---
|
||||||
|
external help file: ModuleRoot-help.xml
|
||||||
|
Module Name: PSCredentialStore
|
||||||
|
online version:
|
||||||
|
schema: 2.0.0
|
||||||
|
---
|
||||||
|
|
||||||
|
# New-CSCertAttribute
|
||||||
|
|
||||||
|
## SYNOPSIS
|
||||||
|
Creates required data for a certificate signing request.
|
||||||
|
|
||||||
|
## SYNTAX
|
||||||
|
|
||||||
|
```
|
||||||
|
New-CSCertAttribute [-Country] <String> [-State] <String> [-City] <String> [-Organization] <String>
|
||||||
|
[-OrganizationalUnitName] <String> [-CommonName] <String> [[-Days] <Int32>] [<CommonParameters>]
|
||||||
|
```
|
||||||
|
|
||||||
|
## DESCRIPTION
|
||||||
|
Defines the certificate related properties for an upcoming New-PfxCertificate execution.
|
||||||
|
|
||||||
|
## EXAMPLES
|
||||||
|
|
||||||
|
### EXAMPLE 1
|
||||||
|
```
|
||||||
|
$AttribParams = @{
|
||||||
|
Country = 'DE'
|
||||||
|
State = 'BW'
|
||||||
|
City = 'Karlsruhe'
|
||||||
|
Organization ='AwesomeIT'
|
||||||
|
OrganizationalUnitName ='PSCredentialStore'
|
||||||
|
CommonName ='MyPrivateCert'
|
||||||
|
}
|
||||||
|
New-CSCertAttribute @AttribParams
|
||||||
|
```
|
||||||
|
|
||||||
|
## PARAMETERS
|
||||||
|
|
||||||
|
### -City
|
||||||
|
Certificate city value.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: 3
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -CommonName
|
||||||
|
The certificate common name.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: 6
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -Country
|
||||||
|
County code like EN, DE, IT, FR...
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: 1
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -Days
|
||||||
|
The validation time itself.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: Int32
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: 7
|
||||||
|
Default value: 365
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -Organization
|
||||||
|
Certificate organization value.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: 4
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -OrganizationalUnitName
|
||||||
|
Certificate OrganizationalUnitName value.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: 5
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -State
|
||||||
|
Certificate state value.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: 2
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### CommonParameters
|
||||||
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
|
## INPUTS
|
||||||
|
|
||||||
|
### [None]
|
||||||
|
## OUTPUTS
|
||||||
|
|
||||||
|
### [PSCredentialStore.Certificate.CSRDetails]
|
||||||
|
## NOTES
|
||||||
|
|
||||||
|
## RELATED LINKS
|
121
docs/New-CSCertificate.md
Normal file
121
docs/New-CSCertificate.md
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
---
|
||||||
|
external help file: ModuleRoot-help.xml
|
||||||
|
Module Name: PSCredentialStore
|
||||||
|
online version:
|
||||||
|
schema: 2.0.0
|
||||||
|
---
|
||||||
|
|
||||||
|
# New-CSCertificate
|
||||||
|
|
||||||
|
## SYNOPSIS
|
||||||
|
Creates a new PFX certificate for the CredentialStore encryption.
|
||||||
|
|
||||||
|
## SYNTAX
|
||||||
|
|
||||||
|
```
|
||||||
|
New-CSCertificate [-CRTAttribute] <Object> [[-KeyName] <String>] [[-CertName] <String>] [-WhatIf] [-Confirm]
|
||||||
|
[<CommonParameters>]
|
||||||
|
```
|
||||||
|
|
||||||
|
## DESCRIPTION
|
||||||
|
Use this function to create a custom self signed certificate used by the PSCredentialStore module.
|
||||||
|
|
||||||
|
## EXAMPLES
|
||||||
|
|
||||||
|
### EXAMPLE 1
|
||||||
|
```
|
||||||
|
New-CSCertificate -CRTAttribute $CRTAttribute -KeyName './myprivate.key' -CertName './mycert.pfx'
|
||||||
|
```
|
||||||
|
|
||||||
|
## PARAMETERS
|
||||||
|
|
||||||
|
### -CertName
|
||||||
|
Provide a custom full path and name for the PFX certificate file.
|
||||||
|
The file extension has to be \`*.pfx\`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: 3
|
||||||
|
Default value: ./certificate.pfx
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -CRTAttribute
|
||||||
|
Provide certificate related attributes provided by function New-CRTAttribute.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: Object
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: 1
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: True (ByValue)
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -KeyName
|
||||||
|
Provide a custom full path and name for the private key.
|
||||||
|
The file extension has to be \`*.key\`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: 2
|
||||||
|
Default value: ./private.key
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -Confirm
|
||||||
|
Prompts you for confirmation before running the cmdlet.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: SwitchParameter
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases: cf
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: Named
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -WhatIf
|
||||||
|
Shows what would happen if the cmdlet runs.
|
||||||
|
The cmdlet is not run.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: SwitchParameter
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases: wi
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: Named
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### CommonParameters
|
||||||
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
|
## INPUTS
|
||||||
|
|
||||||
|
### [PSCredentialStore.Certificate.Attribute]
|
||||||
|
## OUTPUTS
|
||||||
|
|
||||||
|
### [None]
|
||||||
|
## NOTES
|
||||||
|
|
||||||
|
## RELATED LINKS
|
@ -1,92 +1,114 @@
|
|||||||
---
|
---
|
||||||
external help file: PSCredentialStore-help.xml
|
external help file: ModuleRoot-help.xml
|
||||||
Module Name: PSCredentialStore
|
Module Name: PSCredentialStore
|
||||||
online version: https://github.com/OCram85/PSCredentialStore
|
online version:
|
||||||
schema: 2.0.0
|
schema: 2.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
# Get-CredentialStoreItem
|
# New-CredentialStore
|
||||||
|
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
Returns the Credential from a given remote host item.
|
Creates a new credential store File
|
||||||
|
|
||||||
## SYNTAX
|
## SYNTAX
|
||||||
|
|
||||||
### Private (Default)
|
### Private (Default)
|
||||||
```
|
```
|
||||||
Get-CredentialStoreItem -RemoteHost <String> [-Identifier <String>] [<CommonParameters>]
|
New-CredentialStore [-Force] [-PassThru] [-SkipPFXCertCreation] [-UseCertStore] [-WhatIf] [-Confirm]
|
||||||
|
[<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Shared
|
### Shared
|
||||||
```
|
```
|
||||||
Get-CredentialStoreItem -RemoteHost <String> [-Identifier <String>] [-Shared] [-Path <String>]
|
New-CredentialStore [-Shared] [-Path <FileInfo>] [-Force] [-PassThru] [-SkipPFXCertCreation] [-UseCertStore]
|
||||||
[<CommonParameters>]
|
[-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
Return the credential as PSCredential object.
|
You need to run this script first to create a new credential store before you try to
|
||||||
|
save new credentials with New-CredentialStoreItem.
|
||||||
|
|
||||||
## EXAMPLES
|
## EXAMPLES
|
||||||
|
|
||||||
### EXAMPLE 1
|
### EXAMPLE 1
|
||||||
```
|
```
|
||||||
$myCreds = Get-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
New-CredentialStore
|
||||||
|
# Creates a new private CredentialStore
|
||||||
|
```
|
||||||
|
|
||||||
|
### EXAMPLE 2
|
||||||
|
```
|
||||||
|
New-CredentialStore -Force
|
||||||
|
# Resets an existing private CredentialStore
|
||||||
|
```
|
||||||
|
|
||||||
|
### EXAMPLE 3
|
||||||
|
```
|
||||||
|
New-CredentialStore -Shared
|
||||||
|
# Creates a new shared CredentialStore
|
||||||
|
```
|
||||||
|
|
||||||
|
### EXAMPLE 4
|
||||||
|
```
|
||||||
|
New-CredentialStore -Shared -Path "C:\TMP\CredentialStore.json"
|
||||||
|
# Creates a new shared CredentialStore in the given location.
|
||||||
```
|
```
|
||||||
|
|
||||||
## PARAMETERS
|
## PARAMETERS
|
||||||
|
|
||||||
### -Identifier
|
### -Force
|
||||||
Provide a custom identifier to the given remote host key.
|
Use this switch to reset an existing store.
|
||||||
This enables you to store multiple credentials
|
The complete content will be wiped.
|
||||||
for a single remote host entry.
|
|
||||||
For example ad/sys1, ftp/sys1, mssql/sys1
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: SwitchParameter
|
||||||
Parameter Sets: (All)
|
Parameter Sets: (All)
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
Default value: None
|
Default value: False
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -PassThru
|
||||||
|
{{ Fill PassThru Description }}
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: SwitchParameter
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: Named
|
||||||
|
Default value: False
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
||||||
### -Path
|
### -Path
|
||||||
Define a custom path to a shared CredentialStore.
|
Define a location for the new shared CredentialStore.
|
||||||
|
The default store will be created in
|
||||||
|
$Env:ProgramData\PSCredentialStore dir.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: FileInfo
|
||||||
Parameter Sets: Shared
|
Parameter Sets: Shared
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
Default value: "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData
|
|
||||||
Accept pipeline input: False
|
|
||||||
Accept wildcard characters: False
|
|
||||||
```
|
|
||||||
|
|
||||||
### -RemoteHost
|
|
||||||
Specify the host, for which you would like to change the credentials.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
Type: String
|
|
||||||
Parameter Sets: (All)
|
|
||||||
Aliases:
|
|
||||||
|
|
||||||
Required: True
|
|
||||||
Position: Named
|
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
||||||
### -Shared
|
### -Shared
|
||||||
Switch to shared mode with this param.
|
Creates a CredentialStore in the Shared mode.
|
||||||
This enforces the command to work with a shared CredentialStore which
|
This enables you to read the CredentialStore Items on
|
||||||
can be decrypted across systems.
|
different systems or profiles.
|
||||||
|
In addition you can optionally provide a custom path wit the -Path parameter.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: SwitchParameter
|
Type: SwitchParameter
|
||||||
@ -100,25 +122,82 @@ Accept pipeline input: False
|
|||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### -SkipPFXCertCreation
|
||||||
|
You can skip the pfx certificate creation process.
|
||||||
|
This makes sense if you have a previously created cert
|
||||||
|
or want to import a cert in cross-platform environments.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: SwitchParameter
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: Named
|
||||||
|
Default value: False
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -UseCertStore
|
||||||
|
Instead of using a plain pfx file beside your CredentialStore file you can import it into the user or
|
||||||
|
machine certificate store.
|
||||||
|
In this case the system itself secures the cert and you don't hat to set custom
|
||||||
|
NTFS permissions so secure your shared certificate.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: SwitchParameter
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: Named
|
||||||
|
Default value: False
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -Confirm
|
||||||
|
Prompts you for confirmation before running the cmdlet.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: SwitchParameter
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases: cf
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: Named
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -WhatIf
|
||||||
|
Shows what would happen if the cmdlet runs.
|
||||||
|
The cmdlet is not run.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: SwitchParameter
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases: wi
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: Named
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
### CommonParameters
|
### CommonParameters
|
||||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
## INPUTS
|
## INPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## OUTPUTS
|
## OUTPUTS
|
||||||
|
|
||||||
### [System.Management.Automation.PSCredential]
|
### ['PSCredentialStore.Store'] Returns the recently created CredentialStore object if the -PassThru parameter
|
||||||
|
### was given.
|
||||||
## NOTES
|
## NOTES
|
||||||
\`\`\`
|
|
||||||
File Name : Get-CredentialStoreItem.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
## RELATED LINKS
|
## RELATED LINKS
|
||||||
|
|
||||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
external help file: PSCredentialStore-help.xml
|
external help file: ModuleRoot-help.xml
|
||||||
Module Name: PSCredentialStore
|
Module Name: PSCredentialStore
|
||||||
online version: https://github.com/OCram85/PSCredentialStore
|
online version:
|
||||||
schema: 2.0.0
|
schema: 2.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ Aliases:
|
|||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
Default value: "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
@ -104,7 +104,9 @@ Accept wildcard characters: False
|
|||||||
```
|
```
|
||||||
|
|
||||||
### -Shared
|
### -Shared
|
||||||
{{Fill Shared Description}}
|
Define the CredentialStore where you want to add the new item.
|
||||||
|
Default is always personal but can be
|
||||||
|
changed to shared, or even shared with custom path.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: SwitchParameter
|
Type: SwitchParameter
|
||||||
@ -119,24 +121,14 @@ Accept wildcard characters: False
|
|||||||
```
|
```
|
||||||
|
|
||||||
### CommonParameters
|
### CommonParameters
|
||||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
## INPUTS
|
## INPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## OUTPUTS
|
## OUTPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## NOTES
|
## NOTES
|
||||||
\`\`\`
|
|
||||||
File Name : New-CredentialStoreItem.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
## RELATED LINKS
|
## RELATED LINKS
|
||||||
|
|
||||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
---
|
---
|
||||||
Module Name: PSCredentialStore
|
Module Name: PSCredentialStore
|
||||||
Module Guid: 6800e192-9df8-4e30-b253-eb2c799bbe84
|
Module Guid: 6800e192-9df8-4e30-b253-eb2c799bbe84
|
||||||
Download Help Link: {{Please enter FwLink manually}}
|
Download Help Link: {{ Update Download Link }}
|
||||||
Help Version: {{Please enter version of help manually (X.X.X.X) format}}
|
Help Version: {{ Please enter version of help manually (X.X.X.X) format }}
|
||||||
Locale: en-US
|
Locale: en-US
|
||||||
---
|
---
|
||||||
|
|
||||||
# PSCredentialStore Module
|
# PSCredentialStore Module
|
||||||
## Description
|
## Description
|
||||||
{{Manually Enter Description Here}}
|
See global Readme file for usage instructions.
|
||||||
|
|
||||||
## PSCredentialStore Cmdlets
|
## PSCredentialStore Cmdlets
|
||||||
### [Connect-To](Connect-To.md)
|
### [Connect-To](Connect-To.md)
|
||||||
@ -23,12 +23,24 @@ Reads the complete content of the credential store and returns it as a new objec
|
|||||||
### [Get-CredentialStoreItem](Get-CredentialStoreItem.md)
|
### [Get-CredentialStoreItem](Get-CredentialStoreItem.md)
|
||||||
Returns the Credential from a given remote host item.
|
Returns the Credential from a given remote host item.
|
||||||
|
|
||||||
### [Get-CredentialStoreItem](Get-CredentialStoreItem.md)
|
### [Get-CSCertificate](Get-CSCertificate.md)
|
||||||
Returns the Credential from a given remote host item.
|
Returns the current used valid PfX certificate.
|
||||||
|
|
||||||
|
### [Import-CSCertificate](Import-CSCertificate.md)
|
||||||
|
Imports a linked certificate to the valid store location.
|
||||||
|
|
||||||
|
### [New-CredentialStore](New-CredentialStore.md)
|
||||||
|
Creates a new credential store File
|
||||||
|
|
||||||
### [New-CredentialStoreItem](New-CredentialStoreItem.md)
|
### [New-CredentialStoreItem](New-CredentialStoreItem.md)
|
||||||
Adds a credential store item containing host, user and password to the given store.
|
Adds a credential store item containing host, user and password to the given store.
|
||||||
|
|
||||||
|
### [New-CSCertAttribute](New-CSCertAttribute.md)
|
||||||
|
Creates required data for a certificate signing request.
|
||||||
|
|
||||||
|
### [New-CSCertificate](New-CSCertificate.md)
|
||||||
|
Creates a new PFX certificate for the CredentialStore encryption.
|
||||||
|
|
||||||
### [Remove-CredentialStoreItem](Remove-CredentialStoreItem.md)
|
### [Remove-CredentialStoreItem](Remove-CredentialStoreItem.md)
|
||||||
Remove the given credentials from the credential store.
|
Remove the given credentials from the credential store.
|
||||||
|
|
||||||
@ -41,6 +53,12 @@ Returns the credential store state.
|
|||||||
### [Test-CredentialStoreItem](Test-CredentialStoreItem.md)
|
### [Test-CredentialStoreItem](Test-CredentialStoreItem.md)
|
||||||
Checks if the given RemoteHost identifier combination exists in the credential store.
|
Checks if the given RemoteHost identifier combination exists in the credential store.
|
||||||
|
|
||||||
|
### [Test-CSCertificate](Test-CSCertificate.md)
|
||||||
|
Tests if the linked certificate is store ein the specified cert stores.
|
||||||
|
|
||||||
### [Test-CSConnection](Test-CSConnection.md)
|
### [Test-CSConnection](Test-CSConnection.md)
|
||||||
Returns the connection state of a given type to the remote host.
|
Returns the connection state of a given type to the remote host.
|
||||||
|
|
||||||
|
### [Use-CSCertificate](Use-CSCertificate.md)
|
||||||
|
Links an existing PFX Certificate to a CredentialStore.
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
external help file: PSCredentialStore-help.xml
|
external help file: ModuleRoot-help.xml
|
||||||
Module Name: PSCredentialStore
|
Module Name: PSCredentialStore
|
||||||
online version: https://github.com/OCram85/PSCredentialStore
|
online version:
|
||||||
schema: 2.0.0
|
schema: 2.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -30,10 +30,23 @@ Use this CMDLet to completely remove an credential store item.
|
|||||||
|
|
||||||
### EXAMPLE 1
|
### EXAMPLE 1
|
||||||
```
|
```
|
||||||
Remove-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
Remove-CredentialStoreItem -RemoteHost "esx01.myside.local"
|
||||||
```
|
```
|
||||||
|
|
||||||
Remove-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local" -Identifier svc
|
### EXAMPLE 2
|
||||||
|
```
|
||||||
|
Remove-CredentialStoreItem -Shared -RemoteHost "esx01.myside.local"
|
||||||
|
```
|
||||||
|
|
||||||
|
### EXAMPLE 3
|
||||||
|
```
|
||||||
|
Remove-CredentialStoreItem -Shared -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||||
|
```
|
||||||
|
|
||||||
|
### EXAMPLE 4
|
||||||
|
```
|
||||||
|
Remove-CredentialStoreItem -RemoteHost "esx01.myside.local" -Identifier svc
|
||||||
|
```
|
||||||
|
|
||||||
## PARAMETERS
|
## PARAMETERS
|
||||||
|
|
||||||
@ -64,7 +77,7 @@ Aliases:
|
|||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
Default value: "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
@ -102,24 +115,14 @@ Accept wildcard characters: False
|
|||||||
```
|
```
|
||||||
|
|
||||||
### CommonParameters
|
### CommonParameters
|
||||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
## INPUTS
|
## INPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## OUTPUTS
|
## OUTPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## NOTES
|
## NOTES
|
||||||
\`\`\`
|
|
||||||
File Name : Remove-CredentialStoreItem.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
## RELATED LINKS
|
## RELATED LINKS
|
||||||
|
|
||||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
external help file: PSCredentialStore-help.xml
|
external help file: ModuleRoot-help.xml
|
||||||
Module Name: PSCredentialStore
|
Module Name: PSCredentialStore
|
||||||
online version: https://github.com/OCram85/PSCredentialStore
|
online version:
|
||||||
schema: 2.0.0
|
schema: 2.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ Set-CredentialStoreItem -RemoteHost <String> [-Identifier <String>] [-Credential
|
|||||||
```
|
```
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
{{Fill in the Description}}
|
Use this function to update your already stored RemoteHost items.
|
||||||
|
|
||||||
## EXAMPLES
|
## EXAMPLES
|
||||||
|
|
||||||
@ -34,12 +34,15 @@ Set-CredentialStoreItem -RemoteHost <String> [-Identifier <String>] [-Credential
|
|||||||
Set-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
Set-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### EXAMPLE 2
|
||||||
|
```
|
||||||
Set-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local" -Identifier svc
|
Set-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local" -Identifier svc
|
||||||
|
```
|
||||||
|
|
||||||
## PARAMETERS
|
## PARAMETERS
|
||||||
|
|
||||||
### -Credential
|
### -Credential
|
||||||
{{Fill Credential Description}}
|
Provided the new credentials you want to update inside the RemoteHost item.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: PSCredential
|
Type: PSCredential
|
||||||
@ -80,7 +83,7 @@ Aliases:
|
|||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
Default value: "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
@ -118,24 +121,14 @@ Accept wildcard characters: False
|
|||||||
```
|
```
|
||||||
|
|
||||||
### CommonParameters
|
### CommonParameters
|
||||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
## INPUTS
|
## INPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## OUTPUTS
|
## OUTPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## NOTES
|
## NOTES
|
||||||
\`\`\`
|
|
||||||
File Name : Set-CredentialStoreItem.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
## RELATED LINKS
|
## RELATED LINKS
|
||||||
|
|
||||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
|
||||||
|
|
||||||
|
57
docs/Test-CSCertificate.md
Normal file
57
docs/Test-CSCertificate.md
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
---
|
||||||
|
external help file: ModuleRoot-help.xml
|
||||||
|
Module Name: PSCredentialStore
|
||||||
|
online version:
|
||||||
|
schema: 2.0.0
|
||||||
|
---
|
||||||
|
|
||||||
|
# Test-CSCertificate
|
||||||
|
|
||||||
|
## SYNOPSIS
|
||||||
|
Tests if the linked certificate is store ein the specified cert stores.
|
||||||
|
|
||||||
|
## SYNTAX
|
||||||
|
|
||||||
|
```
|
||||||
|
Test-CSCertificate [-Type] <String> [<CommonParameters>]
|
||||||
|
```
|
||||||
|
|
||||||
|
## DESCRIPTION
|
||||||
|
Test-CSCertificate should be an easy high level test for the linked certificate.
|
||||||
|
|
||||||
|
## EXAMPLES
|
||||||
|
|
||||||
|
### EXAMPLE 1
|
||||||
|
```
|
||||||
|
Test-CSCertificate -Type 'Shared'
|
||||||
|
```
|
||||||
|
|
||||||
|
## PARAMETERS
|
||||||
|
|
||||||
|
### -Type
|
||||||
|
Select between 'Private' or 'Shared'.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: 1
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### CommonParameters
|
||||||
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
|
## INPUTS
|
||||||
|
|
||||||
|
### [None]
|
||||||
|
## OUTPUTS
|
||||||
|
|
||||||
|
### [bool]
|
||||||
|
## NOTES
|
||||||
|
|
||||||
|
## RELATED LINKS
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
external help file: PSCredentialStore-help.xml
|
external help file: ModuleRoot-help.xml
|
||||||
Module Name: PSCredentialStore
|
Module Name: PSCredentialStore
|
||||||
online version: https://github.com/OCram85/PSCredentialStore
|
online version:
|
||||||
schema: 2.0.0
|
schema: 2.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ Use this script to check a connection which was established with the \`Connect-T
|
|||||||
|
|
||||||
### EXAMPLE 1
|
### EXAMPLE 1
|
||||||
```
|
```
|
||||||
.\Test-CMConnection -RemoteHost "r0-i01-vcr01.p0r.kivbf-cloud.net" -Type VMware
|
Test-CMConnection -RemoteHost "vcr01.internal.net" -Type VMware
|
||||||
```
|
```
|
||||||
|
|
||||||
## PARAMETERS
|
## PARAMETERS
|
||||||
@ -61,22 +61,14 @@ Accept wildcard characters: False
|
|||||||
```
|
```
|
||||||
|
|
||||||
### CommonParameters
|
### CommonParameters
|
||||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
## INPUTS
|
## INPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## OUTPUTS
|
## OUTPUTS
|
||||||
|
|
||||||
### [Boolean]
|
### [bool]
|
||||||
|
|
||||||
## NOTES
|
## NOTES
|
||||||
File Name : Test-CSConnection.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
|
|
||||||
## RELATED LINKS
|
## RELATED LINKS
|
||||||
|
|
||||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
external help file: PSCredentialStore-help.xml
|
external help file: ModuleRoot-help.xml
|
||||||
Module Name: PSCredentialStore
|
Module Name: PSCredentialStore
|
||||||
online version: https://github.com/OCram85/PSCredentialStore
|
online version:
|
||||||
schema: 2.0.0
|
schema: 2.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -29,12 +29,10 @@ the file exists.
|
|||||||
|
|
||||||
## EXAMPLES
|
## EXAMPLES
|
||||||
|
|
||||||
### Example 1
|
### EXAMPLE 1
|
||||||
```powershell
|
```
|
||||||
PS C:\> {{ Add example code here }}
|
Test-CredentialStore -eq $true
|
||||||
```
|
```
|
||||||
|
|
||||||
{{ Add example description here }}
|
|
||||||
|
|
||||||
## PARAMETERS
|
## PARAMETERS
|
||||||
|
|
||||||
@ -48,7 +46,7 @@ Aliases:
|
|||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
Default value: "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
@ -71,20 +69,13 @@ Accept wildcard characters: False
|
|||||||
```
|
```
|
||||||
|
|
||||||
### CommonParameters
|
### CommonParameters
|
||||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
## INPUTS
|
## INPUTS
|
||||||
|
|
||||||
## OUTPUTS
|
## OUTPUTS
|
||||||
|
|
||||||
|
### System.Boolean
|
||||||
## NOTES
|
## NOTES
|
||||||
\`\`\`
|
|
||||||
File Name : Test-CredentialStore.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
## RELATED LINKS
|
## RELATED LINKS
|
||||||
|
|
||||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
external help file: PSCredentialStore-help.xml
|
external help file: ModuleRoot-help.xml
|
||||||
Module Name: PSCredentialStore
|
Module Name: PSCredentialStore
|
||||||
online version: https://github.com/OCram85/PSCredentialStore
|
online version:
|
||||||
schema: 2.0.0
|
schema: 2.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -28,18 +28,22 @@ Use this cmdlet for basic checks with a single item.
|
|||||||
Check the item first with this function before
|
Check the item first with this function before
|
||||||
you try to interact with it.
|
you try to interact with it.
|
||||||
|
|
||||||
|
Breaking Change for \`v1.1.0+\`:
|
||||||
|
Test-CredentialStoreItem will return \`$false\` even if the store doesn't exist.
|
||||||
|
We removed the terminating
|
||||||
|
error and replaced it with a warning message.
|
||||||
|
|
||||||
## EXAMPLES
|
## EXAMPLES
|
||||||
|
|
||||||
### EXAMPLE 1
|
### EXAMPLE 1
|
||||||
```
|
```
|
||||||
If (Test-CredentialStoreItem -RemoteHost "Default") {
|
if (Test-CredentialStoreItem -RemoteHost "Default") {
|
||||||
```
|
Get-CredentialStoreItem -RemoteHost "Default"
|
||||||
|
|
||||||
Get-CredentialStoreItem -RemoteHost "Default"
|
|
||||||
}
|
}
|
||||||
Else {
|
else {
|
||||||
Write-Warning ("The given Remote Host {0} does not exist in the credential Store!" -f $RemoteHost)
|
Write-Warning ("The given Remote Host {0} does not exist in the credential Store!" -f $RemoteHost)
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## PARAMETERS
|
## PARAMETERS
|
||||||
|
|
||||||
@ -110,24 +114,14 @@ Accept wildcard characters: False
|
|||||||
```
|
```
|
||||||
|
|
||||||
### CommonParameters
|
### CommonParameters
|
||||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
## INPUTS
|
## INPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## OUTPUTS
|
## OUTPUTS
|
||||||
|
|
||||||
### [None]
|
### [None]
|
||||||
|
|
||||||
## NOTES
|
## NOTES
|
||||||
\`\`\`
|
|
||||||
File Name : Test-CredentialStoreItem.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
\`\`\`
|
|
||||||
|
|
||||||
## RELATED LINKS
|
## RELATED LINKS
|
||||||
|
|
||||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
|
||||||
|
|
||||||
|
108
docs/Use-CSCertificate.md
Normal file
108
docs/Use-CSCertificate.md
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
---
|
||||||
|
external help file: ModuleRoot-help.xml
|
||||||
|
Module Name: PSCredentialStore
|
||||||
|
online version:
|
||||||
|
schema: 2.0.0
|
||||||
|
---
|
||||||
|
|
||||||
|
# Use-CSCertificate
|
||||||
|
|
||||||
|
## SYNOPSIS
|
||||||
|
Links an existing PFX Certificate to a CredentialStore.
|
||||||
|
|
||||||
|
## SYNTAX
|
||||||
|
|
||||||
|
### Private (Default)
|
||||||
|
```
|
||||||
|
Use-CSCertificate -Path <String> [-UseCertStore] [<CommonParameters>]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Shared
|
||||||
|
```
|
||||||
|
Use-CSCertificate -Path <String> [-CredentialStore <String>] [-Shared] [-UseCertStore] [<CommonParameters>]
|
||||||
|
```
|
||||||
|
|
||||||
|
## DESCRIPTION
|
||||||
|
Linking a certificate is needed if you plan to use the same CredentialStore in cross platform scenarios.
|
||||||
|
|
||||||
|
## EXAMPLES
|
||||||
|
|
||||||
|
### EXAMPLE 1
|
||||||
|
```
|
||||||
|
Use-CSCertificate -Path 'C:\cert.pfx'
|
||||||
|
```
|
||||||
|
|
||||||
|
## PARAMETERS
|
||||||
|
|
||||||
|
### -CredentialStore
|
||||||
|
Specify a custom path for a shared credential store.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: Shared
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: Named
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -Path
|
||||||
|
Specify the path to the PFX Certificate you want to link for usage.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: Named
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -Shared
|
||||||
|
Use the credential store in shared mode.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: SwitchParameter
|
||||||
|
Parameter Sets: Shared
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: Named
|
||||||
|
Default value: False
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -UseCertStore
|
||||||
|
Use the given certificate and import it into the corresponding certificate store.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: SwitchParameter
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: Named
|
||||||
|
Default value: False
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### CommonParameters
|
||||||
|
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||||
|
|
||||||
|
## INPUTS
|
||||||
|
|
||||||
|
### [None]
|
||||||
|
## OUTPUTS
|
||||||
|
|
||||||
|
### [None]
|
||||||
|
## NOTES
|
||||||
|
|
||||||
|
## RELATED LINKS
|
@ -1,4 +1,4 @@
|
|||||||
# PSCredentialStore
|
# PSCredentialStore
|
||||||
## about_PSCredentialStore
|
## about_PSCredentialStore
|
||||||
|
|
||||||
|
|
||||||
@ -7,24 +7,60 @@ PSCredentialStore enables managing multiple PSCredential objects.
|
|||||||
|
|
||||||
|
|
||||||
# LONG DESCRIPTION
|
# LONG DESCRIPTION
|
||||||
The PSCredentialStore is an simple credential manager for PSCredentials. It stores multiple credential objects in a
|
The PSCredentialStore is a simple credential manager for `PSCredential` objects. It stores PSCredentials in a simple json
|
||||||
simple json file. You can choose between a private and shared store. The private one exists in your profile and can
|
file. You can choose between a private and shared credential store. The private one exists in your profile and can
|
||||||
ony accessed by your account on the same machine. The shared store enables you to use different credentials for your
|
ony accessed by your account on the same machine. The shared store enables you to use different credentials for your
|
||||||
script without exposing them as plain text.
|
scripts without exposing them as plain text.
|
||||||
|
|
||||||
**The shared store isn't 100% secure and I don't recommend using it in production!**
|
|
||||||
|
|
||||||
PSCredentialStore was developed to simplify the delegation of complex powershell scripts. In this case you often
|
PSCredentialStore was developed to simplify the delegation of complex powershell scripts. In this case you often
|
||||||
need to store credentials for non interactive usage like in scheduled tasks.
|
need to store credentials for non interactive usage like in scheduled tasks.
|
||||||
|
|
||||||
To get started read the [about_PSCredentialStore](/src/en-US/about_PSCredential.help.txt) page.
|
Starting with version `1.0.0` PSCredential uses Pfx certificates fo encryption. You can use Pfx certificate files
|
||||||
|
or certificates stored in the certificate store.
|
||||||
|
|
||||||
|
For more details read the [about_PSCredentialStore](/docs/about_PSCredentialStore.md) page on gitea or via CLI with
|
||||||
|
`Get-Help about_PSCredentialStore`.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- PowerShell >= `5.1`
|
||||||
|
- .NET Framework >= `4.6` or .NET Core >= `1.0`
|
||||||
|
|
||||||
|
## About Security
|
||||||
|
|
||||||
|
>This section explains some security topics and the the design decisions we made to balance the usage and security needs.
|
||||||
|
|
||||||
|
To be able to delegate `PSCredentials` objects we can't exclusively rely on the `SecureString` cmdlets. You can't
|
||||||
|
decrypt and reuse such credentials from a different user account or even machine. This is caused by automatically
|
||||||
|
generated encryption key which, is used create a `Secure String` based encrypted string.
|
||||||
|
|
||||||
|
In order to delegate a password, while still using the underlying security framework, we have to provide a custom
|
||||||
|
encryption key. This leads to the fact, that everyone who has access to the key could encrypt or decrypt your data.
|
||||||
|
|
||||||
|
So we decided to use the public and private keys from valid certificates as part of the custom encryption keys to encrypt your data.
|
||||||
|
|
||||||
|
This means clearly: Everyone who has access to the `CredentialStore` needs also access to the certificate file to work with it.
|
||||||
|
|
||||||
|
Keep in mind you need to secure the access with your NTFS file permissions to avoid unwanted usage. Another option is
|
||||||
|
to import the certificate into your certification vaults of you operating system. In this case you can grand the
|
||||||
|
permission to the certificates itself.
|
||||||
|
|
||||||
|
Here is s brief hierarchy description of the certificate location: *(First match wins)*
|
||||||
|
|
||||||
|
| CredentialStore Type | Certificate Location |
|
||||||
|
| -------------------- | ---------------------- |
|
||||||
|
| Private | `CurrentUser`\\`My` |
|
||||||
|
| Shared (Windows) | `CurrentUser`\\`My` |
|
||||||
|
| | `LocalMachine`\\`Root` |
|
||||||
|
| Shared (Linux) | `LocalMachine`\\`My` |
|
||||||
|
| | `LocalMachine`\\`Root` |
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
## PowerShellGallery.com (Recommended Way)
|
## PowerShellGallery.com (Recommended Way)
|
||||||
|
|
||||||
* Make sure you use PowerShell 4.0 or higher with `$PSVersionTable`.
|
* Make sure you use PowerShell 5.1 or higher with `$PSVersionTable`.
|
||||||
* Use the builtin PackageManagement and install with: `Install-Module PSCredentialStore`
|
* Use the builtin PackageManagement and install with: `Install-Module PSCredentialStore`
|
||||||
* Done. Start exploring the Module with `Import-Module PSCredentialStore ; Get-Command -Module PSCredentialStore`
|
* Done. Start exploring the Module with `Import-Module PSCredentialStore ; Get-Command -Module PSCredentialStore`
|
||||||
|
|
||||||
@ -36,19 +72,28 @@ To get started read the [about_PSCredentialStore](/src/en-US/about_PSCredential.
|
|||||||
* Don't forget to change the NTFS permission flag in the context menu.
|
* Don't forget to change the NTFS permission flag in the context menu.
|
||||||
* Start with `Import-Module PSCredentialStore`
|
* Start with `Import-Module PSCredentialStore`
|
||||||
|
|
||||||
**1.** First we need a blank CredentialStore. You can decide between a *private* or *shared* store. The private
|
**1.** First we need a blank credential store. You can decide between a *private* or *shared* store. The private
|
||||||
Credential Store can only be accessed with your profile on the machine you created it.
|
Credential Store can only be accessed with your profile on the machine you created it.
|
||||||
|
|
||||||
|
Starting with version `1.0.0` you can decide the storage type of your fresh created certificate. As default
|
||||||
|
PSCredentialStore creates a new pfx certificate file beside the credential store itself. Optionally you can provide
|
||||||
|
the parameter `-UseCertStore`. This imports the new certificate in the user or machine certificate store as well.
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# Private Credential Store
|
# Private credential store
|
||||||
New-CredentialStore
|
New-CredentialStore
|
||||||
|
|
||||||
# Shared Credential Store
|
# Private credential store with certificate store usage
|
||||||
|
New-CredentialStore -UseCertStore
|
||||||
|
|
||||||
|
# Shared credential store
|
||||||
New-CredentialStore -Shared
|
New-CredentialStore -Shared
|
||||||
|
|
||||||
#Shared CredentialStore in custom Location
|
#Shared credential store in custom Location
|
||||||
New-CredentialStore -Shared -Path 'C:\CredentialStore.json'
|
New-CredentialStore -Shared -Path 'C:\CredentialStore.json'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
**2.** Now you can manage your CredentialStoreItems:
|
**2.** Now you can manage your CredentialStoreItems:
|
||||||
```powershell
|
```powershell
|
||||||
# This will prompt for credentials and stores it in a private store
|
# This will prompt for credentials and stores it in a private store
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
{
|
|
||||||
"Version": 0.1,
|
|
||||||
"Mandatory": {},
|
|
||||||
"Optional": [
|
|
||||||
{
|
|
||||||
"Name": "foobar2000",
|
|
||||||
"Modules": [
|
|
||||||
"foobar2000"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "foo",
|
|
||||||
"Modules": [
|
|
||||||
"foo",
|
|
||||||
"bar"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "bar",
|
|
||||||
"Modules": [
|
|
||||||
"bar"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "Existing",
|
|
||||||
"Modules": [
|
|
||||||
"PowerShellGet"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "PSGetMixed",
|
|
||||||
"Modules": [
|
|
||||||
"PowerShellGet",
|
|
||||||
"foobar2000"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
139
resources/PSScriptAnalyzerSettings.psd1
Normal file
139
resources/PSScriptAnalyzerSettings.psd1
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
@{
|
||||||
|
Severity = 'Error', 'Warning', 'Information'
|
||||||
|
|
||||||
|
IncludeRules = @(
|
||||||
|
'PSAlignAssignmentStatement',
|
||||||
|
'PSAvoidAssignmentToAutomaticVariable',
|
||||||
|
'AvoidDefaultValueForMandatoryParameter',
|
||||||
|
'PSAvoidDefaultValueSwitchParameter',
|
||||||
|
'PSAvoidGlobalAliases',
|
||||||
|
'ÜSAvoidGlobalFunctions',
|
||||||
|
'PSAvoidGlobalVars',
|
||||||
|
'PSAvoidInvokingEmptyMembers',
|
||||||
|
'PSAvoidLongLines',
|
||||||
|
'PSAvoidNullOrEmptyHelpMessageAttribute',
|
||||||
|
'PSAvoidOverwritingBuiltInCmdlets',
|
||||||
|
'PSAvoidShouldContinueWithoutForce',
|
||||||
|
'PSAvoidTrailingWhitespace',
|
||||||
|
'PSAvoidUsingCmdletAliases',
|
||||||
|
'PSAvoidUsingComputerNameHardcoded',
|
||||||
|
'PSAvoidUsingConvertToSecureStringWithPlainText',
|
||||||
|
'PSAvoidUsingDeprecatedManifestFields',
|
||||||
|
'PSAvoidUsingDoubleQuotesForConstantString',
|
||||||
|
'PSAvoidUsingEmptyCatchBlock',
|
||||||
|
'PSAvoidUsingInvokeExpression',
|
||||||
|
'PSAvoidUsingPlainTextForPassword',
|
||||||
|
'PSAvoidUsingPositionalParameters',
|
||||||
|
'PSAvoidUsingUsernameAndPasswordParams',
|
||||||
|
'PSAvoidUsingWMICmdlet',
|
||||||
|
'PSAvoidUsingWriteHost',
|
||||||
|
'PSMisleadingBacktick',
|
||||||
|
'PSMissingModuleManifestField',
|
||||||
|
'PSPlaceCloseBrace',
|
||||||
|
'PSPlaceOpenBrace',
|
||||||
|
'PSPossibleIncorrectComparisonWithNull',
|
||||||
|
'PSPossibleIncorrectUsageOfAssignmentOperator',
|
||||||
|
'PSPossibleIncorrectUsageOfRedirectionOperator',
|
||||||
|
'PSProvideCommentHelp',
|
||||||
|
'PSReservedCmdletChar',
|
||||||
|
'PSReservedParams',
|
||||||
|
'PSReviewUnusedParameter',
|
||||||
|
'PSShouldProcess',
|
||||||
|
'PSUseApprovedVerbs',
|
||||||
|
'PSUseBOMForUnicodeEncodedFile',
|
||||||
|
'PSUseCmdletCorrectly',
|
||||||
|
'PSUseCompatibleCmdlets',
|
||||||
|
#'PSUseCompatibleCommands',
|
||||||
|
'PSUseCompatibleSyntax',
|
||||||
|
#'PSUseCompatibleTypes',
|
||||||
|
'PSUseConsistentIndentation',
|
||||||
|
'PSUseConsistentWhitespace',
|
||||||
|
'PSUseCorrectCasing',
|
||||||
|
'PSUseDeclaredVarsMoreThanAssignments',
|
||||||
|
'PSUseLiteralInitializerForHashtable',
|
||||||
|
'PSUseOutputTypeCorrectly',
|
||||||
|
'PSUsePSCredentialType',
|
||||||
|
'PSUseProcessBlockForPipelineCommand',
|
||||||
|
'PSUseShouldProcessForStateChangingFunctions',
|
||||||
|
'PSUseSingularNouns',
|
||||||
|
'PSUseSupportsShouldProcess',
|
||||||
|
'PSUseToExportFieldsInManifest',
|
||||||
|
'PSUseUTF8EncodingForHelpFile',
|
||||||
|
'PSUseUsingScopeModifierInNewRunspaces'
|
||||||
|
)
|
||||||
|
|
||||||
|
Rules = @{
|
||||||
|
|
||||||
|
PSAvoidLongLines = @{
|
||||||
|
Enable = $true
|
||||||
|
MaximumLineLength = 116
|
||||||
|
}
|
||||||
|
|
||||||
|
PSPlaceOpenBrace = @{
|
||||||
|
Enable = $true
|
||||||
|
OnSameLine = $true
|
||||||
|
NewLineAfter = $true
|
||||||
|
IgnoreOneLineBlock = $true
|
||||||
|
}
|
||||||
|
|
||||||
|
PSPlaceCloseBrace = @{
|
||||||
|
Enable = $true
|
||||||
|
NewLineAfter = $true
|
||||||
|
IgnoreOneLineBlock = $true
|
||||||
|
NoEmptyLineBefore = $false
|
||||||
|
}
|
||||||
|
|
||||||
|
PSProvideCommentHelp = @{
|
||||||
|
Enable = $true
|
||||||
|
ExportedOnly = $false
|
||||||
|
BlockComment = $true
|
||||||
|
VSCodeSnippetCorrection = $false
|
||||||
|
Placement = "begin"
|
||||||
|
}
|
||||||
|
|
||||||
|
PSUseCompatibleCmdlets = @{
|
||||||
|
compatibility = @(
|
||||||
|
"desktop-5.1.14393.206-windows",
|
||||||
|
"core-6.1.0-windows"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
PSUseCompatibleSyntax = @{
|
||||||
|
Enable = $true
|
||||||
|
TargetVersions = @(
|
||||||
|
"7.0",
|
||||||
|
"5.1"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
PSUseConsistentIndentation = @{
|
||||||
|
Enable = $true
|
||||||
|
Kind = 'space'
|
||||||
|
PipelineIndentation = 'IncreaseIndentationForFirstPipeline'
|
||||||
|
IndentationSize = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
PSUseConsistentWhitespace = @{
|
||||||
|
Enable = $true
|
||||||
|
CheckInnerBrace = $true
|
||||||
|
CheckOpenBrace = $true
|
||||||
|
CheckOpenParen = $true
|
||||||
|
CheckOperator = $true
|
||||||
|
CheckPipe = $true
|
||||||
|
CheckPipeForRedundantWhitespace = $false
|
||||||
|
CheckSeparator = $true
|
||||||
|
CheckParameter = $false
|
||||||
|
IgnoreAssignmentOperatorInsideHashTable = $true
|
||||||
|
}
|
||||||
|
|
||||||
|
PSAlignAssignmentStatement = @{
|
||||||
|
Enable = $true
|
||||||
|
CheckHashtable = $false
|
||||||
|
}
|
||||||
|
|
||||||
|
PSUseCorrectCasing = @{
|
||||||
|
Enable = $true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,81 +1,66 @@
|
|||||||
function Get-CSCertificate {
|
function Get-CSCertificate {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Returns the certificate object given by thumbprint.
|
Returns the current used valid PfX certificate.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
You can use this function to get a stored certificate. Search for the object by its unique thumbprint.
|
Use this function to get the available pfx certificate respecting the config hierarchy.
|
||||||
|
|
||||||
|
.PARAMETER Type
|
||||||
|
Select the current credential store type.
|
||||||
|
|
||||||
.PARAMETER Thumbprint
|
.PARAMETER Thumbprint
|
||||||
Provide one or more thumprints.
|
Provide the credentials thumbprint for the search.
|
||||||
|
|
||||||
.PARAMETER StoreName
|
|
||||||
Select the store name in which you want to search the certificates.
|
|
||||||
|
|
||||||
.PARAMETER StoreLocation
|
|
||||||
Select between the both available locations CurrentUser odr LocalMachine.
|
|
||||||
|
|
||||||
.INPUTS
|
.INPUTS
|
||||||
[string]
|
[None]
|
||||||
|
|
||||||
.OUTPUTS
|
.OUTPUTS
|
||||||
[System.Security.Cryptography.X509Certificates.X509Certificate2[]]
|
[System.Security.Cryptography.X509Certificates.X509Certificate2]
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Get-CSCertificate -Thumbprint '12345678' -StoreName 'My' -StoreLocation 'CurrentUser'
|
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 (
|
||||||
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string[]]$Thumbprint,
|
[ValidateSet('Private', 'Shared')]
|
||||||
|
[string]$Type,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $true)]
|
||||||
[ValidateSet(
|
[ValidateNotNullOrEmpty()]
|
||||||
'AddressBook',
|
[string]$Thumbprint
|
||||||
'AuthRoot',
|
|
||||||
'CertificateAuthority',
|
|
||||||
'Disallowed',
|
|
||||||
'My',
|
|
||||||
'Root',
|
|
||||||
'TrustedPeople',
|
|
||||||
'TrustedPublisher'
|
|
||||||
)]
|
|
||||||
[string]$StoreName = 'My',
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[ValidateSet(
|
|
||||||
'CurrentUser',
|
|
||||||
'LocalMachine'
|
|
||||||
)]
|
|
||||||
[string]$StoreLocation = 'CurrentUser'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {}
|
||||||
$Store = [System.Security.Cryptography.X509Certificates.X509Store]::New($StoreName, $StoreLocation)
|
|
||||||
try {
|
|
||||||
$Store.Open('ReadOnly')
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
$_.Exception.Message | Write-Error -ErrorAction Stop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($Thumb in $Thumbprint) {
|
if ($Type -eq 'Private') {
|
||||||
Write-Output $Store.Certificates | Where-Object { $_.Thumbprint -eq $Thumb }
|
Get-CSPfXCertificate -Thumbprint $Thumbprint -StoreName 'My' -StoreLocation 'CurrentUser'
|
||||||
|
}
|
||||||
|
elseif ($Type -eq 'Shared') {
|
||||||
|
if ( $isLinux) {
|
||||||
|
$cert = Get-CSPfxCertificate -Thumbprint $Thumbprint -StoreName 'My' -StoreLocation 'CurrentUser'
|
||||||
|
if ($null -eq $cert) {
|
||||||
|
Get-CSPfxCertificate -Thumbprint $Thumbprint -StoreName 'Root' -StoreLocation 'LocalMachine'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Output $cert
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end {
|
elseif ( (! $isLinux) -or ($isWindows) ) {
|
||||||
$Store.Close()
|
$cert = Get-CSPfxCertificate -Thumbprint $Thumbprint -StoreName 'My' -StoreLocation 'LocalMachine'
|
||||||
|
if ($null -eq $cert) {
|
||||||
|
Get-CSPfxCertificate -Thumbprint $Thumbprint -StoreName 'Root' -StoreLocation 'LocalMachine'
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Write-Output $cert
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end {}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
function Import-CSCertificate {
|
function Import-CSCertificate {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
adds a given pfx certificate file to current uerers personal certificate store.
|
Imports a linked certificate to the valid store location.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This function is used to import existing pfx certificate files. The Import-PFXCertificate cmdle from the
|
Import-CSCertificate takes a pfx certificate file and imports it to the supposed certificate store for
|
||||||
PKI module imports the certficate into a deprecated store. Thus you can't read the private key afterwards or
|
private and shared credential stores.
|
||||||
using it for decrypting data.
|
|
||||||
|
.PARAMETER Type
|
||||||
|
Select between the a private and shared credential store.
|
||||||
|
|
||||||
.PARAMETER Path
|
.PARAMETER Path
|
||||||
Path to an existing *.pfx certificate file.
|
Provide a valid path to pfx certificate file.
|
||||||
|
|
||||||
.PARAMETER StoreName
|
|
||||||
Additionally you change change the store where you want the certificate into.
|
|
||||||
|
|
||||||
.INPUTS
|
.INPUTS
|
||||||
[None]
|
[None]
|
||||||
@ -21,92 +20,45 @@ function Import-CSCertificate {
|
|||||||
[None]
|
[None]
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Import-CSCertificate -Path (Join-Path -Path $Env:APPDATA -ChildPath '/PSCredentialStore.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()]
|
||||||
[string]$Path,
|
[ValidateSet('Private', 'Shared')]
|
||||||
|
[string]$Type,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $true)]
|
||||||
[ValidateSet(
|
[ValidateNotNullOrEmpty()]
|
||||||
'AddressBook',
|
[System.IO.FileInfo]$Path
|
||||||
'AuthRoot',
|
|
||||||
'CertificateAuthority',
|
|
||||||
'Disallowed',
|
|
||||||
'My',
|
|
||||||
'Root',
|
|
||||||
'TrustedPeople',
|
|
||||||
'TrustedPublisher'
|
|
||||||
)]
|
|
||||||
[string]$StoreName = 'My',
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[ValidateSet(
|
|
||||||
'CurrentUser',
|
|
||||||
'LocalMachine'
|
|
||||||
)]
|
|
||||||
[string]$StoreLocation = 'CurrentUser',
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[ValidateSet(
|
|
||||||
'ReadOnly',
|
|
||||||
'ReadWrite',
|
|
||||||
'MaxAllowed',
|
|
||||||
'OpenExistingOnly',
|
|
||||||
'InclueArchived'
|
|
||||||
)]
|
|
||||||
[string]$OpenFlags = 'ReadWrite'
|
|
||||||
)
|
)
|
||||||
begin {
|
begin {
|
||||||
$Store = [System.Security.Cryptography.X509Certificates.X509Store]::new($StoreName, $StoreLocation)
|
if (! (Test-Path -Path $Path)) {
|
||||||
try {
|
|
||||||
$Store.Open($OpenFlags)
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
$_.Exception.Message | Write-Error -ErrorAction Stop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
process {
|
|
||||||
try {
|
|
||||||
$cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new(
|
|
||||||
$Path,
|
|
||||||
$null,
|
|
||||||
(
|
|
||||||
[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable -bor
|
|
||||||
[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::PersistKeySet
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if (Test-CSCertificate -Thumbprint $cert.Thumbprint) {
|
|
||||||
Write-Warning -Message ('The certificate with thumbprint {0} is already present!' -f $cert.Thumbprint)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$Store.Add($cert)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
$_.Exception.Message | Write-Error -ErrorAction Stop
|
|
||||||
$ErrorParams = @{
|
$ErrorParams = @{
|
||||||
ErrorAction = 'Stop'
|
ErrorAction = 'Stop'
|
||||||
Exception = [System.Exception]::new(
|
Exception = [System.Exception]::new(
|
||||||
'Could not read or add the pfx certificate!'
|
('File {0} not found!') -f $Path
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Write-Error @ErrorParams
|
Write-Error @ErrorParams
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
# Import to CurrentUser\My store for windows and linux
|
||||||
|
if ($Type -eq 'Private') {
|
||||||
|
Import-CSPfxCertificate -Path $Path -StoreName 'My' -StoreLocation 'CurrentUser' -OpenFlags 'ReadWrite'
|
||||||
|
}
|
||||||
|
elseif ( (! $isLinux ) -and ($Type -eq 'Shared') ) {
|
||||||
|
Import-CSPfxCertificate -Path $Path -StoreName 'My' -StoreLocation 'LocalMachine' -OpenFlags 'ReadWrite'
|
||||||
|
}
|
||||||
|
elseif ( ($isLinux) -and ($Type -eq 'Shared') ) {
|
||||||
|
Import-CSPfxCertificate -Path $Path -StoreName 'My' -StoreLocation 'CurrentUser' -OpenFlags 'ReadWrite'
|
||||||
|
}
|
||||||
|
}
|
||||||
end {
|
end {
|
||||||
$Store.Close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
src/Certificate/New-CSCertAttribute.Tests.ps1
Normal file
20
src/Certificate/New-CSCertAttribute.Tests.ps1
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
BeforeAll {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
Import-Module $ManifestFile -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
Describe "New-CSCertAttribute" {
|
||||||
|
Context "Basis Tests" -Tag 'Unit' {
|
||||||
|
It "Should not throw" {
|
||||||
|
$AttribParams = @{
|
||||||
|
Country = 'DE'
|
||||||
|
State = 'BW'
|
||||||
|
City = 'KA'
|
||||||
|
Organization = 'IT'
|
||||||
|
OrganizationalUnitName = 'foo'
|
||||||
|
CommonName = 'MyCert'
|
||||||
|
}
|
||||||
|
{ New-CSCertAttribute @AttribParams } | Should -Not -Throw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,13 @@
|
|||||||
function New-CRTAttribute {
|
function New-CSCertAttribute {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Create required data for a certificate signing request.
|
Creates required data for a certificate signing request.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Defines the certificate related properties for an upcoming New-PfxCertificate execution.
|
Defines the certificate related properties for an upcoming New-PfxCertificate execution.
|
||||||
|
|
||||||
.PARAMETER Country
|
.PARAMETER Country
|
||||||
Provide a two letter country code.
|
County code like EN, DE, IT, FR...
|
||||||
|
|
||||||
.PARAMETER State
|
.PARAMETER State
|
||||||
Certificate state value.
|
Certificate state value.
|
||||||
@ -24,30 +24,35 @@ function New-CRTAttribute {
|
|||||||
.PARAMETER CommonName
|
.PARAMETER CommonName
|
||||||
The certificate common name.
|
The certificate common name.
|
||||||
|
|
||||||
.PARAMETER CSRSubject
|
.PARAMETER Days
|
||||||
you can provide the needed certificate properties with in one hashtable. This hashtable has to contain the
|
The validation time itself.
|
||||||
following keys: 'Country', 'State', 'City', 'Organization', 'OrganizationalUnitName', 'CommonName'.
|
|
||||||
|
|
||||||
.INPUTS
|
.INPUTS
|
||||||
[None]
|
[None]
|
||||||
|
|
||||||
.OUTPUTS
|
.OUTPUTS
|
||||||
['PSCredentialStore.Certificate.CSRDetails']
|
[PSCredentialStore.Certificate.CSRDetails]
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
New-CRTAttribute -CSRSubject @{Country = 'DE'; State = 'BW'; City = 'Karlsruhe'; Organization = 'AwesomeIT'; OrganizationalUnitName = '';CommonName = 'MyPrivateCert'}
|
$AttribParams = @{
|
||||||
|
Country = 'DE'
|
||||||
.NOTES
|
State = 'BW'
|
||||||
File Name : New-CSRDetails.ps1
|
City = 'Karlsruhe'
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
Organization ='AwesomeIT'
|
||||||
Requires :
|
OrganizationalUnitName ='PSCredentialStore'
|
||||||
|
CommonName ='MyPrivateCert'
|
||||||
.LINK
|
}
|
||||||
https://github.com/OCram85/PSCredentialStore
|
New-CSCertAttribute @AttribParams
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
|
'PSUseShouldProcessForStateChangingFunctions',
|
||||||
|
'',
|
||||||
|
Justification = 'Returns a new object and does not change data'
|
||||||
|
)]
|
||||||
[OutputType('PSCredentialStore.Certificate.Attribute')]
|
[OutputType('PSCredentialStore.Certificate.Attribute')]
|
||||||
param(
|
param (
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[ValidateLength(2, 2)]
|
[ValidateLength(2, 2)]
|
||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
@ -77,9 +82,8 @@ function New-CRTAttribute {
|
|||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
[int]$Days = 365
|
[int]$Days = 365
|
||||||
)
|
)
|
||||||
begin {
|
begin {}
|
||||||
|
|
||||||
}
|
|
||||||
process {
|
process {
|
||||||
return [PSCustomObject]@{
|
return [PSCustomObject]@{
|
||||||
PSTypeName = 'PSCredentialStore.Certificate.Attribute'
|
PSTypeName = 'PSCredentialStore.Certificate.Attribute'
|
||||||
@ -95,6 +99,5 @@ function New-CRTAttribute {
|
|||||||
Days = $Days
|
Days = $Days
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end {
|
end {}
|
||||||
}
|
|
||||||
}
|
}
|
33
src/Certificate/New-CSCertificate.Tests.ps1
Normal file
33
src/Certificate/New-CSCertificate.Tests.ps1
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
BeforeAll {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
Import-Module $ManifestFile -Force
|
||||||
|
|
||||||
|
$PrivateFunctions = (Get-ChildItem -Path "./src/Private/*.ps1" | Where-Object {
|
||||||
|
$_.BaseName -notmatch '.Tests'
|
||||||
|
}
|
||||||
|
).FullName
|
||||||
|
foreach ( $func in $PrivateFunctions) {
|
||||||
|
. $func
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Describe "New-CSCertificate" {
|
||||||
|
Context "Basic Tests" -Tag 'Unit' {
|
||||||
|
It "Should not throw" {
|
||||||
|
$attribs = @{
|
||||||
|
Country = 'DE'
|
||||||
|
State = 'BW'
|
||||||
|
City = 'KA'
|
||||||
|
Organization = 'IT'
|
||||||
|
OrganizationalUnitName = 'foo'
|
||||||
|
CommonName = 'MyCert'
|
||||||
|
}
|
||||||
|
$CertAttribs = @{
|
||||||
|
CRTAttribute = New-CSCertAttribute @attribs
|
||||||
|
KeyName = Join-Path -Path (Get-TempDir) -ChildPath '/foo.key'
|
||||||
|
CertName = Join-Path -Path (Get-TempDir) -ChildPath '/cert.pfx'
|
||||||
|
}
|
||||||
|
{ New-CSCertificate @CertAttribs } | Should -Not -Throw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
function New-PfxCertificate {
|
function New-CSCertificate {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Creates new PFX certificate for the CredentialStore encryption.
|
Creates a new PFX certificate for the CredentialStore encryption.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Use this function to create a custom self signed certificate used by the PSCredentialStore module.
|
Use this function to create a custom self signed certificate used by the PSCredentialStore module.
|
||||||
@ -22,19 +22,17 @@ function New-PfxCertificate {
|
|||||||
[None]
|
[None]
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
New-PfxCertificate -CRTAttribute $CRTAttribute -KeyName './myprivate.key' -CertName './mycert.pfx'
|
New-CSCertificate -CRTAttribute $CRTAttribute -KeyName './myprivate.key' -CertName './mycert.pfx'
|
||||||
|
|
||||||
.NOTES
|
|
||||||
File Name : New-PfxCertificate.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(SupportsShouldProcess = $true)]
|
[CmdletBinding(SupportsShouldProcess = $true)]
|
||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
|
'PSAvoidUsingInvokeExpression',
|
||||||
|
'',
|
||||||
|
Justification = 'needed for openssl wrapping'
|
||||||
|
)]
|
||||||
[OutputType()]
|
[OutputType()]
|
||||||
param(
|
param (
|
||||||
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
|
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[PSTypeName('PSCredentialStore.Certificate.Attribute')]$CRTAttribute,
|
[PSTypeName('PSCredentialStore.Certificate.Attribute')]$CRTAttribute,
|
||||||
@ -64,12 +62,16 @@ function New-PfxCertificate {
|
|||||||
Write-Error @ErrorParams
|
Write-Error @ErrorParams
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (($PSVersionTable.PSEdition -eq 'Desktop' -and $PSVersionTable.PSVersion.Major -lt 6) -or ($IsWindows -eq $true)) {
|
elseif (
|
||||||
$openssl = Join-Path -Path $ModuleBase -ChildPath '/Vendor/libressl255/openssl.exe'
|
($PSVersionTable.PSEdition -eq 'Desktop' -and $PSVersionTable.PSVersion.Major -lt 6) -or
|
||||||
|
($IsWindows -eq $true)
|
||||||
|
) {
|
||||||
|
$openssl = Join-Path -Path $ModuleBase -ChildPath '/Vendor/libressl/openssl.exe'
|
||||||
}
|
}
|
||||||
|
|
||||||
$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 = @(
|
||||||
@ -83,7 +85,9 @@ function New-PfxCertificate {
|
|||||||
$Subj = $SubjPattern -f $SubjValues
|
$Subj = $SubjPattern -f $SubjValues
|
||||||
|
|
||||||
$PEMCertName = $CertName -replace '.pfx', '.crt'
|
$PEMCertName = $CertName -replace '.pfx', '.crt'
|
||||||
$ExpPattern = '& ''{0}'' req -x509 -sha256 -nodes -days {1} -newkey rsa:2048 -keyout {2} -out {3} -subj "{4}" *>$null'
|
$ExpPattern = (
|
||||||
|
'& ''{0}'' req -x509 -sha256 -nodes -days {1} -newkey rsa:2048 -keyout {2} -out {3} -subj "{4}" *>$null'
|
||||||
|
)
|
||||||
$ExpValues = @(
|
$ExpValues = @(
|
||||||
$openssl,
|
$openssl,
|
||||||
$CRTAttribute.Days
|
$CRTAttribute.Days
|
@ -1,19 +1,13 @@
|
|||||||
function Test-CSCertificate {
|
function Test-CSCertificate {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Tests if the given certificate exists in a store.
|
Tests if the linked certificate is store ein the specified cert stores.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Use this function to ensure if a certificate is already imported into a given store.
|
Test-CSCertificate should be an easy high level test for the linked certificate.
|
||||||
|
|
||||||
.PARAMETER Thumbprint
|
.PARAMETER Type
|
||||||
Provide one or more thumprints.
|
Select between 'Private' or 'Shared'.
|
||||||
|
|
||||||
.PARAMETER StoreName
|
|
||||||
Select the store name in which you want to search the certificates.
|
|
||||||
|
|
||||||
.PARAMETER StoreLocation
|
|
||||||
Select between the both available locations CurrentUser odr LocalMachine.
|
|
||||||
|
|
||||||
.INPUTS
|
.INPUTS
|
||||||
[None]
|
[None]
|
||||||
@ -22,58 +16,66 @@ function Test-CSCertificate {
|
|||||||
[bool]
|
[bool]
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Test-CSCertificate -Thumbprint '12345678' -StoreName 'My' -StoreLocation 'CurrentUser'
|
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([bool])]
|
||||||
param(
|
param (
|
||||||
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$Thumbprint,
|
[ValidateSet('Private', 'Shared')]
|
||||||
|
[string]$Type
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[ValidateSet(
|
|
||||||
'AddressBook',
|
|
||||||
'AuthRoot',
|
|
||||||
'CertificateAuthority',
|
|
||||||
'Disallowed',
|
|
||||||
'My',
|
|
||||||
'Root',
|
|
||||||
'TrustedPeople',
|
|
||||||
'TrustedPublisher'
|
|
||||||
)]
|
|
||||||
[string]$StoreName = 'My',
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[ValidateSet(
|
|
||||||
'CurrentUser',
|
|
||||||
'LocalMachine'
|
|
||||||
)]
|
|
||||||
[string]$StoreLocation = 'CurrentUser'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
$Store = [System.Security.Cryptography.X509Certificates.X509Store]::New($StoreName, $StoreLocation)
|
if ($Type -eq 'Private') {
|
||||||
try {
|
$CS = Get-CredentialStore
|
||||||
$Store.Open('ReadOnly')
|
|
||||||
}
|
}
|
||||||
catch {
|
elseif ($Type -eq 'Shared') {
|
||||||
$_.Exception.Message | Write-Error -ErrorAction Stop
|
$CS = Get-CredentialStore -Shared
|
||||||
}
|
}
|
||||||
|
if ($null -ne $CS.PfxCertificate) {
|
||||||
|
Write-Warning -Message (
|
||||||
|
'There is a Pfx certificate file linked in the store. ' +
|
||||||
|
'Certificates saved in the Cert store will be ignored!'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
process {
|
process {
|
||||||
$Cert = $Store.Certificates | Where-Object { $_.Thumbprint -eq $Thumbprint }
|
if ($Type -eq 'Private') {
|
||||||
|
$cert = Get-CSPfXCertificate -Thumbprint $CS.Thumbprint -StoreName 'My' -StoreLocation 'CurrentUser'
|
||||||
if ($null -eq $Cert) {
|
}
|
||||||
|
elseif ($Type -eq 'Shared') {
|
||||||
|
if ( $isLinux) {
|
||||||
|
$cert = Get-CSPfxCertificate -Thumbprint $CS.Thumbprint -StoreName 'My' -StoreLocation 'CurrentUser'
|
||||||
|
if ($null -eq $cert) {
|
||||||
|
$PFXParams = @{
|
||||||
|
Thumbprint = $CS.Thumbprint
|
||||||
|
StoreName = 'Root'
|
||||||
|
StoreLocation = 'LocalMachine'
|
||||||
|
}
|
||||||
|
$cert = Get-CSPfxCertificate @PFXParams
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ( (! $isLinux) -or ($isWindows) ) {
|
||||||
|
$PFXParams = @{
|
||||||
|
Thumbprint = $CS.Thumbprint
|
||||||
|
StoreName = 'My'
|
||||||
|
StoreLocation = 'LocalMachine'
|
||||||
|
}
|
||||||
|
$cert = Get-CSPfxCertificate @PFXParams
|
||||||
|
if ($null -eq $cert) {
|
||||||
|
$PFXParams = @{
|
||||||
|
Thumbprint = $CS.Thumbprint
|
||||||
|
StoreName = 'Root'
|
||||||
|
StoreLocation = 'LocalMachine'
|
||||||
|
}
|
||||||
|
$cert = Get-CSPfxCertificate @PFXParams
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($null -eq $cert) {
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -81,6 +83,5 @@ function Test-CSCertificate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
end {
|
end {
|
||||||
$Store.Close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
function Use-PfxCertificate {
|
function Use-CSCertificate {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Links an existing PFX Certifiacte to a CredentialStore.
|
Links an existing PFX Certificate to a CredentialStore.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Linking a certificate is needed if you plan to use the same CredentialStore in cross platform scenarios.
|
Linking a certificate is needed if you plan to use the same CredentialStore in cross platform scenarios.
|
||||||
@ -9,6 +9,15 @@ function Use-PfxCertificate {
|
|||||||
.PARAMETER Path
|
.PARAMETER Path
|
||||||
Specify the path to the PFX Certificate you want to link for usage.
|
Specify the path to the PFX Certificate you want to link for usage.
|
||||||
|
|
||||||
|
.PARAMETER CredentialStore
|
||||||
|
Specify a custom path for a shared credential store.
|
||||||
|
|
||||||
|
.PARAMETER Shared
|
||||||
|
Use the credential store in shared mode.
|
||||||
|
|
||||||
|
.PARAMETER UseCertStore
|
||||||
|
Use the given certificate and import it into the corresponding certificate store.
|
||||||
|
|
||||||
.INPUTS
|
.INPUTS
|
||||||
[None]
|
[None]
|
||||||
|
|
||||||
@ -16,31 +25,27 @@ function Use-PfxCertificate {
|
|||||||
[None]
|
[None]
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
|
Use-CSCertificate -Path 'C:\cert.pfx'
|
||||||
|
|
||||||
.NOTES
|
|
||||||
File Name : Use-PfxCertificate.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 = 'Shared')]
|
||||||
|
[switch]$UseCertStore
|
||||||
)
|
)
|
||||||
begin {}
|
begin {}
|
||||||
|
|
||||||
@ -61,11 +66,11 @@ function Use-PfxCertificate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
@ -93,8 +98,14 @@ Make sure you used the same AES keys for encrypting!
|
|||||||
"@
|
"@
|
||||||
}
|
}
|
||||||
|
|
||||||
$CS.PfxCertificate = $validPath.Path
|
if ($UseCertStore) {
|
||||||
|
Import-CSCertificate -Type $PSCmdlet.ParameterSetName -Path $Path
|
||||||
$CS.Thumbprint = $PfxCertificate.Thumbprint
|
$CS.Thumbprint = $PfxCertificate.Thumbprint
|
||||||
|
$CS.PfxCertificate = $null
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$CS.PfxCertificate = $validPath.Path
|
||||||
|
}
|
||||||
$CS | ConvertTo-Json -Depth 5 | Out-File -FilePath $StorePath -Force -Encoding utf8
|
$CS | ConvertTo-Json -Depth 5 | Out-File -FilePath $StorePath -Force -Encoding utf8
|
||||||
}
|
}
|
||||||
|
|
@ -15,7 +15,16 @@ function Connect-To {
|
|||||||
|
|
||||||
.PARAMETER Type
|
.PARAMETER Type
|
||||||
Specify the host type of the target. Currently implemented targets are: Possible connection values are:
|
Specify the host type of the target. Currently implemented targets are: Possible connection values are:
|
||||||
CiscoUcs, FTP, NetAppFAS, VMware, CisServer, ExchangeHTTP, ExchangeHTTPS, SCP.
|
|
||||||
|
- CiscoUcs
|
||||||
|
- CiscoUcsCentral
|
||||||
|
- CisServer
|
||||||
|
- ExchangeHTTP
|
||||||
|
- ExchangeHTTPS
|
||||||
|
- FTP
|
||||||
|
- NetAppFAS
|
||||||
|
- SCP
|
||||||
|
- VMware
|
||||||
|
|
||||||
.PARAMETER Credentials
|
.PARAMETER Credentials
|
||||||
Use this parameter to bypass the stored credentials. Without this parameter Connect-To tries to read the
|
Use this parameter to bypass the stored credentials. Without this parameter Connect-To tries to read the
|
||||||
@ -29,6 +38,9 @@ function Connect-To {
|
|||||||
Switch to shared mode with this param. This enforces the command to work with a shared CredentialStore which
|
Switch to shared mode with this param. This enforces the command to work with a shared CredentialStore which
|
||||||
can be decrypted across systems.
|
can be decrypted across systems.
|
||||||
|
|
||||||
|
.PARAMETER PassThru
|
||||||
|
Returns the value from the underlying connection type function.
|
||||||
|
|
||||||
.INPUTS
|
.INPUTS
|
||||||
[None]
|
[None]
|
||||||
|
|
||||||
@ -38,6 +50,9 @@ function Connect-To {
|
|||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Connect-To -RemoteHost "ucs.myside.local" -Type CiscoUcs
|
Connect-To -RemoteHost "ucs.myside.local" -Type CiscoUcs
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Connect-To -RemoteHost "ucscentral.myside.local" -Type 'CiscoUcsCentral'
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
|
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
|
||||||
|
|
||||||
@ -55,30 +70,28 @@ function Connect-To {
|
|||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Connect-To -RemoteHost "exchange01.myside.local" -Type ExchangeHTTPS
|
Connect-To -RemoteHost "exchange01.myside.local" -Type ExchangeHTTPS
|
||||||
|
|
||||||
.NOTES
|
|
||||||
File Name : Connect-To.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||||
param(
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
'PSAvoidGlobalVars',
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
'',
|
||||||
|
Justification = 'Wrapping existing var from WinSCP module.'
|
||||||
|
)]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||||
|
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||||
[string]$RemoteHost,
|
[string]$RemoteHost,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||||
[string]$Identifier,
|
[string]$Identifier,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||||
[ValidateSet(
|
[ValidateSet(
|
||||||
'CiscoUcs',
|
'CiscoUcs',
|
||||||
|
'CiscoUcsCentral',
|
||||||
'FTP',
|
'FTP',
|
||||||
'NetAppFAS',
|
'NetAppFAS',
|
||||||
'VMware',
|
'VMware',
|
||||||
@ -89,38 +102,34 @@ function Connect-To {
|
|||||||
)]
|
)]
|
||||||
[string]$Type,
|
[string]$Type,
|
||||||
|
|
||||||
[Parameter(Mandatory = $False, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $False, ParameterSetName = 'Shared')]
|
||||||
[Parameter(Mandatory = $False, ParameterSetName = "Private")]
|
[Parameter(Mandatory = $False, ParameterSetName = 'Private')]
|
||||||
[PSCredential]$Credentials,
|
[PSCredential]$Credentials,
|
||||||
|
|
||||||
[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()]
|
||||||
[string]$Path,
|
[string]$Path,
|
||||||
|
|
||||||
[Parameter(Mandatory = $False, ParameterSetName = "Private")]
|
[Parameter(Mandatory = $False, ParameterSetName = 'Private')]
|
||||||
[Parameter(Mandatory = $False, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $False, ParameterSetName = 'Shared')]
|
||||||
[switch]$PassThru
|
[switch]$PassThru
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
# 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# First check the optional modules
|
|
||||||
if (-not (Resolve-Dependency -Name $Type)) {
|
|
||||||
Write-Error -Message ("Could not resolve the optional dependencies defined for {0}" -f $Type) -ErrorAction 'Stop'
|
|
||||||
}
|
|
||||||
switch ($Type) {
|
switch ($Type) {
|
||||||
"VMware" {
|
"VMware" {
|
||||||
# Disable the yellow certificate warning, since we haven't replaced the SSL certs for vCenter/ESXi
|
# Disable the yellow certificate warning, since we haven't replaced the SSL certs for vCenter/ESXi
|
||||||
@ -151,8 +160,11 @@ function Connect-To {
|
|||||||
|
|
||||||
catch {
|
catch {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to look up credential store item for RemoteHost {0}/Identifier {1}!" -f $RemoteHost, $Identifier
|
Message = (
|
||||||
ErrorAction = "Stop"
|
"Unable to look up credential store item for RemoteHost " +
|
||||||
|
("{0}/Identifier {1}!" -f $RemoteHost, $Identifier)
|
||||||
|
)
|
||||||
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -161,10 +173,10 @@ function Connect-To {
|
|||||||
$creds = $Credentials
|
$creds = $Credentials
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($creds.UserName -eq "" -or $creds.Password.GetType().Name -ne "SecureString") {
|
if ($creds.UserName -eq "" -or $creds.Password.GetType().Name -ne 'SecureString') {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Please provide valid credentials for RemoteHost {0}!" -f $RemoteHost
|
Message = "Please provide valid credentials for RemoteHost {0}!" -f $RemoteHost
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -172,14 +184,28 @@ function Connect-To {
|
|||||||
switch ($Type) {
|
switch ($Type) {
|
||||||
"CiscoUcs" {
|
"CiscoUcs" {
|
||||||
try {
|
try {
|
||||||
$handle = Connect-Ucs -Name $RemoteHost -Credential $creds -ErrorAction Stop
|
$handle = Connect-Ucs -Name $RemoteHost -Credential $creds -ErrorAction 'Stop' -NotDefault
|
||||||
$ExecutionContext.SessionState.PSVariable.Set("DefaultUcs", $handle)
|
$ExecutionContext.SessionState.PSVariable.Set('DefaultUcs', $handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
catch {
|
catch {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
|
}
|
||||||
|
Write-Error @MessageParams
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"CiscoUcsCentral" {
|
||||||
|
try {
|
||||||
|
$handle = Connect-UcsCentral -Name $RemoteHost -Credential $creds -NotDefault
|
||||||
|
$ExecutionContext.SessionState.PSVariable.Set('DefaultUcsCentral', $handle)
|
||||||
|
}
|
||||||
|
|
||||||
|
catch {
|
||||||
|
$MessageParams = @{
|
||||||
|
Message = ('Unable to connect to {0} using {1}' -f $RemoteHost, $Type)
|
||||||
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -194,7 +220,7 @@ function Connect-To {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$FTPSessionOption = New-WinSCPSessionOption @WinSCPConParams
|
$FTPSessionOption = New-WinSCPSessionOption @WinSCPConParams
|
||||||
$Global:WinSCPSession = New-WinSCPSession @FTPSessionOption
|
$Global:WinSCPSession = New-WinSCPSession -SessionOption $FTPSessionOption
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
throw "Could not connect to {0} using {1} protocol!" -f $RemoteHost, $Type
|
throw "Could not connect to {0} using {1} protocol!" -f $RemoteHost, $Type
|
||||||
@ -203,8 +229,11 @@ function Connect-To {
|
|||||||
if (!($WinSCPSession.Opened)) {
|
if (!($WinSCPSession.Opened)) {
|
||||||
# Check the connection state and find out if the session is still open.
|
# Check the connection state and find out if the session is still open.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Connection to {0} using Type {1} was established. But now it seems to be lost!" -f $RemoteHost, $Type
|
Message = (
|
||||||
ErrorAction = "Stop"
|
("Connection to {0} using Type {1} " -f $RemoteHost, $Type) +
|
||||||
|
"was established. But now it seems to be lost!"
|
||||||
|
)
|
||||||
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -218,7 +247,7 @@ function Connect-To {
|
|||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -232,7 +261,7 @@ function Connect-To {
|
|||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -252,7 +281,7 @@ function Connect-To {
|
|||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -266,12 +295,14 @@ function Connect-To {
|
|||||||
ErrorAction = 'Stop'
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
|
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
|
||||||
|
# ScriptAnalyzer issue (unused var) workaround.
|
||||||
|
$null = $Global:PSExchangeRemote
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -290,7 +321,7 @@ function Connect-To {
|
|||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -305,13 +336,15 @@ function Connect-To {
|
|||||||
try {
|
try {
|
||||||
$SessionOption = New-WinSCPSessionOption @WinSCPSessionParams
|
$SessionOption = New-WinSCPSessionOption @WinSCPSessionParams
|
||||||
$Global:WinSCPSession = New-WinSCPSession -SessionOption $SessionOption
|
$Global:WinSCPSession = New-WinSCPSession -SessionOption $SessionOption
|
||||||
Write-Verbose -Message ("SCP Connection established with {0}" -f $Global:WinSCPSession.Hostname)
|
Write-Verbose -Message (
|
||||||
|
"SCP Connection established with {0}" -f $Global:WinSCPSession.Hostname
|
||||||
|
)
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -319,8 +352,11 @@ function Connect-To {
|
|||||||
if (!($WinSCPSession.Opened)) {
|
if (!($WinSCPSession.Opened)) {
|
||||||
# Check the connection state and find out if the session is still open.
|
# Check the connection state and find out if the session is still open.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Connection to {0} using Type {1} was established. But now it seems to be lost!" -f $RemoteHost, $Type
|
Message = (
|
||||||
ErrorAction = "Stop"
|
("Connection to {0} using Type {1} was established. " -f $RemoteHost, $Type) +
|
||||||
|
"But now it seems to be lost!"
|
||||||
|
)
|
||||||
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -329,7 +365,7 @@ function Connect-To {
|
|||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,17 @@ function Disconnect-From {
|
|||||||
same hostname.
|
same hostname.
|
||||||
|
|
||||||
.PARAMETER Type
|
.PARAMETER Type
|
||||||
Specify the host type of the target. Currently implemented targets are: CiscoUcs, FTP, NetAppFAS, VMware,
|
Specify the host type of the target. Currently implemented targets are:
|
||||||
CisServer, ExchangeHTTP, ExchangeHTTPS, SCP.
|
|
||||||
|
- CiscoUcs
|
||||||
|
- CiscoUcsCentral
|
||||||
|
- FTP
|
||||||
|
- NetAppFAS
|
||||||
|
- VMware
|
||||||
|
- CisServer
|
||||||
|
- ExchangeHTTP
|
||||||
|
- ExchangeHTTPS
|
||||||
|
- SCP
|
||||||
|
|
||||||
.PARAMETER Force
|
.PARAMETER Force
|
||||||
Force the disconnect, even if the disconnect would fail.
|
Force the disconnect, even if the disconnect would fail.
|
||||||
@ -49,24 +58,22 @@ function Disconnect-From {
|
|||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Disconnect-From -RemoteHost "exchange01.myside.local" -Type ExchangeHTTPS
|
Disconnect-From -RemoteHost "exchange01.myside.local" -Type ExchangeHTTPS
|
||||||
|
|
||||||
.NOTES
|
|
||||||
File Name : Disconnect-From.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
|
'PSAvoidGlobalVars',
|
||||||
|
'',
|
||||||
|
Justification = 'Wrapping existing global vars from external modules'
|
||||||
|
)]
|
||||||
|
param (
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$RemoteHost,
|
[string]$RemoteHost,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[ValidateSet(
|
[ValidateSet(
|
||||||
'CiscoUcs',
|
'CiscoUcs',
|
||||||
|
'CiscoUcsCentral',
|
||||||
'FTP',
|
'FTP',
|
||||||
'NetAppFAS',
|
'NetAppFAS',
|
||||||
'VMware',
|
'VMware',
|
||||||
@ -81,14 +88,17 @@ function Disconnect-From {
|
|||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
|
begin {}
|
||||||
|
|
||||||
|
process {
|
||||||
switch -Regex ($Type) {
|
switch -Regex ($Type) {
|
||||||
"VMware" {
|
"VMware" {
|
||||||
try {
|
try {
|
||||||
if ($Force) {
|
if ($Force) {
|
||||||
Disconnect-VIServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop -Force:$true
|
Disconnect-VIServer -Server $RemoteHost -Confirm:$false -ErrorAction 'Stop' -Force:$true
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Disconnect-VIServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop
|
Disconnect-VIServer -Server $RemoteHost -Confirm:$false -ErrorAction 'Stop'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +106,7 @@ function Disconnect-From {
|
|||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -104,10 +114,10 @@ function Disconnect-From {
|
|||||||
"CisServer" {
|
"CisServer" {
|
||||||
try {
|
try {
|
||||||
if ($Force) {
|
if ($Force) {
|
||||||
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop -Force:$true
|
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction 'Stop' -Force:$true
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop
|
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction 'Stop'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +125,7 @@ function Disconnect-From {
|
|||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -127,8 +137,8 @@ function Disconnect-From {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "There is no open WinSCP Session"
|
Message = 'There is no open WinSCP Session'
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -138,8 +148,10 @@ function Disconnect-From {
|
|||||||
"NetAppFAS" {
|
"NetAppFAS" {
|
||||||
try {
|
try {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Setting {0} to `$null, which will disconnect NetAppFAS" -f $Global:CurrentNcController
|
Message = (
|
||||||
ErrorAction = "Continue"
|
"Setting {0} to `$null, which will disconnect NetAppFAS" -f $Global:CurrentNcController
|
||||||
|
)
|
||||||
|
ErrorAction = 'Continue'
|
||||||
}
|
}
|
||||||
Write-Verbose @MessageParams
|
Write-Verbose @MessageParams
|
||||||
$Global:CurrentNcController = $null
|
$Global:CurrentNcController = $null
|
||||||
@ -149,7 +161,7 @@ function Disconnect-From {
|
|||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -164,20 +176,34 @@ function Disconnect-From {
|
|||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"ExchangeHTTP*" {
|
"CiscoUCSCentral" {
|
||||||
try {
|
try {
|
||||||
Get-Variable -Name 'PSExchangeRemote' -Scope Global -ErrorAction Stop
|
$handle = Connect-UcsCentral -Name $RemoteHost -Credential $creds -NotDefault
|
||||||
Remove-PSSession -Session $Global:PSExchangeRemote -ErrorAction Stop
|
$ExecutionContext.SessionState.PSVariable.Set('DefaultUcsCentral', $handle)
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
|
}
|
||||||
|
Write-Error @MessageParams
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"ExchangeHTTP*" {
|
||||||
|
try {
|
||||||
|
Get-Variable -Name 'PSExchangeRemote' -Scope 'Global' -ErrorAction 'Stop'
|
||||||
|
Remove-PSSession -Session $Global:PSExchangeRemote -ErrorAction 'Stop'
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$MessageParams = @{
|
||||||
|
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -188,8 +214,8 @@ function Disconnect-From {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "There is no open WinSCP Session"
|
Message = 'There is no open WinSCP Session'
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -198,9 +224,10 @@ function Disconnect-From {
|
|||||||
# Write a error message to the log.
|
# Write a error message to the log.
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,28 +17,20 @@ function Test-CSConnection {
|
|||||||
[None]
|
[None]
|
||||||
|
|
||||||
.OUTPUTS
|
.OUTPUTS
|
||||||
[Boolean]
|
[bool]
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
.\Test-CMConnection -RemoteHost "r0-i01-vcr01.p0r.kivbf-cloud.net" -Type VMware
|
Test-CMConnection -RemoteHost "vcr01.internal.net" -Type VMware
|
||||||
|
|
||||||
.NOTES
|
|
||||||
File Name : Test-CSConnection.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([boolean])]
|
[OutputType([bool])]
|
||||||
param(
|
param (
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$RemoteHost,
|
[string]$RemoteHost,
|
||||||
|
|
||||||
[Parameter(Mandatory = $True)]
|
[Parameter(Mandatory = $true)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[ValidateSet("CiscoUcs", "FTP", "NetAppFAS", "VMware")]
|
[ValidateSet("CiscoUcs", "FTP", "NetAppFAS", "VMware")]
|
||||||
[string]$Type
|
[string]$Type
|
||||||
|
35
src/Formats/PSCredential.Store.Format.ps1xml
Normal file
35
src/Formats/PSCredential.Store.Format.ps1xml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<Configuration>
|
||||||
|
<ViewDefinitions>
|
||||||
|
<View>
|
||||||
|
<Name>PSCredentialStore.Store</Name>
|
||||||
|
<ViewSelectedBy>
|
||||||
|
<TypeName>PSCredentialStore.Store</TypeName>
|
||||||
|
</ViewSelectedBy>
|
||||||
|
<ListControl>
|
||||||
|
<ListEntries>
|
||||||
|
<ListEntry>
|
||||||
|
<ListItems>
|
||||||
|
<ListItem>
|
||||||
|
<PropertyName>Version</PropertyName>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem>
|
||||||
|
<PropertyName>Created</PropertyName>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem>
|
||||||
|
<Label>PfxCertificate</Label>
|
||||||
|
<ScriptBlock>$_.PfxCertificate | Split-Path -Leaf</ScriptBlock>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem>
|
||||||
|
<PropertyName>Thumbprint</PropertyName>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem>
|
||||||
|
<PropertyName>Type</PropertyName>
|
||||||
|
</ListItem>
|
||||||
|
</ListItems>
|
||||||
|
</ListEntry>
|
||||||
|
</ListEntries>
|
||||||
|
</ListControl>
|
||||||
|
</View>
|
||||||
|
</ViewDefinitions>
|
||||||
|
</Configuration>
|
43
src/Formats/PSCredentialStore.Certificate.Attribute.ps1xml
Normal file
43
src/Formats/PSCredentialStore.Certificate.Attribute.ps1xml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<Configuration>
|
||||||
|
<ViewDefinitions>
|
||||||
|
<View>
|
||||||
|
<Name>PSCredentialStore.Certificate.Attribute</Name>
|
||||||
|
<ViewSelectedBy>
|
||||||
|
<TypeName>PSCredentialStore.Certificate.Attribute</TypeName>
|
||||||
|
</ViewSelectedBy>
|
||||||
|
<ListControl>
|
||||||
|
<ListEntries>
|
||||||
|
<ListEntry>
|
||||||
|
<ListItems>
|
||||||
|
<ListItem>
|
||||||
|
<Label>Country</Label>
|
||||||
|
<ScriptBlock>$_.Subject.Country</ScriptBlock>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem>
|
||||||
|
<Label>State</Label>
|
||||||
|
<ScriptBlock>$_.Subject.State</ScriptBlock>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem>
|
||||||
|
<Label>City</Label>
|
||||||
|
<ScriptBlock>$_.Subject.City</ScriptBlock>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem>
|
||||||
|
<Label>Organization</Label>
|
||||||
|
<ScriptBlock>$_.Subject.Organization</ScriptBlock>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem>
|
||||||
|
<Label>OrganizationalUnitName</Label>
|
||||||
|
<ScriptBlock>$_.Subject.OrganizationalUnitName</ScriptBlock>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem>
|
||||||
|
<Label>CommonName</Label>
|
||||||
|
<ScriptBlock>$_.Subject.CommonName</ScriptBlock>
|
||||||
|
</ListItem>
|
||||||
|
</ListItems>
|
||||||
|
</ListEntry>
|
||||||
|
</ListEntries>
|
||||||
|
</ListControl>
|
||||||
|
</View>
|
||||||
|
</ViewDefinitions>
|
||||||
|
</Configuration>
|
@ -29,34 +29,25 @@ function Get-CredentialStoreItem {
|
|||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
$myCreds = Get-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
$myCreds = Get-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||||
|
|
||||||
.NOTES
|
|
||||||
```
|
|
||||||
File Name : Get-CredentialStoreItem.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
```
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||||
[OutputType([PSCredential])]
|
[OutputType([PSCredential])]
|
||||||
param(
|
param (
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$RemoteHost,
|
[string]$RemoteHost,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$Identifier,
|
[string]$Identifier,
|
||||||
|
|
||||||
[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()]
|
||||||
[string]$Path
|
[string]$Path
|
||||||
)
|
)
|
||||||
@ -64,10 +55,10 @@ function Get-CredentialStoreItem {
|
|||||||
begin {
|
begin {
|
||||||
# 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
|
||||||
}
|
}
|
||||||
@ -86,25 +77,13 @@ function Get-CredentialStoreItem {
|
|||||||
$CS = Get-CredentialStore -Shared -Path $Path
|
$CS = Get-CredentialStore -Shared -Path $Path
|
||||||
$CSMembers = Get-Member -InputObject $CS
|
$CSMembers = Get-Member -InputObject $CS
|
||||||
# Let's first check if the given remote host exists as object property
|
# Let's first check if the given remote host exists as object property
|
||||||
if (($CSMembers.MemberType -eq "NoteProperty") -and ($CSMembers.Name -contains $CredentialName)) {
|
if (($CSMembers.MemberType -eq 'NoteProperty') -and ($CSMembers.Name -contains $CredentialName)) {
|
||||||
try {
|
|
||||||
if ($null -eq $CS.PfxCertificate) {
|
if ($null -eq $CS.PfxCertificate) {
|
||||||
$Cert = Get-CSCertificate -Thumbprint $CS.Thumbprint
|
$Cert = Get-CSCertificate -Type $CS.Type -Thumbprint $CS.Thumbprint
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$Cert = Get-PfxCertificate -FilePath $CS.PfxCertificate -ErrorAction Stop
|
$Cert = Get-PfxCertificate -FilePath $CS.PfxCertificate -ErrorAction Stop
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch {
|
|
||||||
$_.Exception.Message | Write-Error
|
|
||||||
$ErrorParams = @{
|
|
||||||
ErrorAction = 'Stop'
|
|
||||||
Exception = [System.Security.Cryptography.CryptographicException]::new(
|
|
||||||
'Could not read the given PFX certificate.'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Write-Error @ErrorParams
|
|
||||||
}
|
|
||||||
$DecryptedKey = $Cert.PrivateKey.Decrypt(
|
$DecryptedKey = $Cert.PrivateKey.Decrypt(
|
||||||
[Convert]::FromBase64String($CS.$CredentialName.EncryptedKey),
|
[Convert]::FromBase64String($CS.$CredentialName.EncryptedKey),
|
||||||
[System.Security.Cryptography.RSAEncryptionPadding]::Pkcs1
|
[System.Security.Cryptography.RSAEncryptionPadding]::Pkcs1
|
||||||
@ -119,16 +98,16 @@ function Get-CredentialStoreItem {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$MsgParams = @{
|
$MsgParams = @{
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
Message = "Could not find credentials for the given remote host: {0}" -f $RemoteHost
|
Message = 'Could not find credentials for the given remote host: {0}' -f $RemoteHost
|
||||||
}
|
}
|
||||||
Write-Error @MsgParams
|
Write-Error @MsgParams
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$MsgParams = @{
|
$MsgParams = @{
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
Message = "The given credential store ({0}) does not exist!" -f $Path
|
Message = 'The given credential store ({0}) does not exist!' -f $Path
|
||||||
}
|
}
|
||||||
Write-Error @MsgParams
|
Write-Error @MsgParams
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,31 @@
|
|||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
|
'PSAvoidUsingConvertToSecureStringWithPlainText',
|
||||||
|
'',
|
||||||
|
Justification = 'just used in pester tests.'
|
||||||
|
)]
|
||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
|
'PSProvideCommentHelp',
|
||||||
|
'',
|
||||||
|
Justification = 'no need in internal pester helpers.'
|
||||||
|
)]
|
||||||
|
param ()
|
||||||
|
|
||||||
|
BeforeAll {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
Import-Module $ManifestFile -Force
|
||||||
|
|
||||||
|
$PrivateFunctions = (Get-ChildItem -Path "./src/Private/*.ps1" | Where-Object {
|
||||||
|
$_.BaseName -notmatch '.Tests'
|
||||||
|
}
|
||||||
|
).FullName
|
||||||
|
foreach ( $func in $PrivateFunctions) {
|
||||||
|
. $func
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Describe "New-CredentialStoreItem" {
|
Describe "New-CredentialStoreItem" {
|
||||||
Context "Private Credential Store tests" {
|
Context "Private Credential Store tests" {
|
||||||
It "Test1: Add entry to existing private store." {
|
It "Add entry to existing private store." {
|
||||||
# Creat a fresh CredentialStore first
|
# Creat a fresh CredentialStore first
|
||||||
New-CredentialStore -Force
|
New-CredentialStore -Force
|
||||||
|
|
||||||
@ -20,7 +45,7 @@ Describe "New-CredentialStoreItem" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Context "Test with new shared Credential Store" {
|
Context "Test with new shared Credential Store" {
|
||||||
It "Test2: Create new RemoteHost entry" {
|
It "Create new RemoteHost entry" {
|
||||||
# prepare test environment
|
# prepare test environment
|
||||||
$tmpCS = Join-Path -Path (Get-TempDir) -ChildPath '/CredentialStore.json'
|
$tmpCS = Join-Path -Path (Get-TempDir) -ChildPath '/CredentialStore.json'
|
||||||
New-CredentialStore -Shared -Path $tmpCS -Force
|
New-CredentialStore -Shared -Path $tmpCS -Force
|
||||||
@ -29,9 +54,11 @@ Describe "New-CredentialStoreItem" {
|
|||||||
$Password = ConvertTo-SecureString -String "mypasswd" -AsPlainText -Force
|
$Password = ConvertTo-SecureString -String "mypasswd" -AsPlainText -Force
|
||||||
$mycreds = [PSCredential]::new($UserName, $Password)
|
$mycreds = [PSCredential]::new($UserName, $Password)
|
||||||
$RemoteHost = "foobar"
|
$RemoteHost = "foobar"
|
||||||
{ New-CredentialStoreItem -Shared -Path $tmpCS -RemoteHost $RemoteHost -Credential $mycreds } | Should -Not -Throw
|
{
|
||||||
|
New-CredentialStoreItem -Shared -Path $tmpCS -RemoteHost $RemoteHost -Credential $mycreds
|
||||||
|
} | Should -Not -Throw
|
||||||
$tmpCS = Get-Content -Path $tmpCS -Raw | ConvertFrom-Json
|
$tmpCS = Get-Content -Path $tmpCS -Raw | ConvertFrom-Json
|
||||||
$res = Get-Member -InputObject $tmpCS -Name $RemoteHost -Membertype Properties
|
$res = Get-Member -InputObject $tmpCS -Name $RemoteHost -MemberType Properties
|
||||||
$res.Name | Should -Be $RemoteHost
|
$res.Name | Should -Be $RemoteHost
|
||||||
}
|
}
|
||||||
It "Adds Item with identifier to shared store" {
|
It "Adds Item with identifier to shared store" {
|
||||||
@ -42,13 +69,19 @@ Describe "New-CredentialStoreItem" {
|
|||||||
$Password = ConvertTo-SecureString -String "mypasswd" -AsPlainText -Force
|
$Password = ConvertTo-SecureString -String "mypasswd" -AsPlainText -Force
|
||||||
$mycreds = [PSCredential]::new($UserName, $Password)
|
$mycreds = [PSCredential]::new($UserName, $Password)
|
||||||
$RemoteHost = "foobar2"
|
$RemoteHost = "foobar2"
|
||||||
New-CredentialStoreItem -Shared -Path $tmpCS -RemoteHost $RemoteHost -Credential $mycreds -Identifier 'Foo'
|
$StoreItemParam = @{
|
||||||
|
Shared = $true
|
||||||
|
Path = $tmpCS
|
||||||
|
RemoteHost = $RemoteHost
|
||||||
|
Credential = $mycreds
|
||||||
|
identifier = 'Foo'
|
||||||
|
}
|
||||||
|
New-CredentialStoreItem @StoreItemParam
|
||||||
$writtenItem = Get-CredentialStoreItem -Shared -Path $tmpCS -RemoteHost $RemoteHost -Identifier 'Foo'
|
$writtenItem = Get-CredentialStoreItem -Shared -Path $tmpCS -RemoteHost $RemoteHost -Identifier 'Foo'
|
||||||
($writtenItem.UserName -eq $UserName) -and ($writtenItem.Password.Length -gt 0) | Should -Be $true
|
($writtenItem.UserName -eq $UserName) -and ($writtenItem.Password.Length -gt 0) | Should -Be $true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Context "Test optional parameter lookup" {
|
Context "Test optional parameter lookup" {
|
||||||
|
|
||||||
It "Test missing Credential" {
|
It "Test missing Credential" {
|
||||||
function global:Get-Credential ([string]$Message) {
|
function global:Get-Credential ([string]$Message) {
|
||||||
$UserName = 'testuser'
|
$UserName = 'testuser'
|
||||||
@ -65,16 +98,20 @@ Describe "New-CredentialStoreItem" {
|
|||||||
|
|
||||||
}
|
}
|
||||||
Context "General Exception handling" {
|
Context "General Exception handling" {
|
||||||
Mock Test-CredentialStore { return $false }
|
Mock Test-CredentialStore { return $false } -ModuleName 'PSCredentialStore'
|
||||||
It "Missing CredentialStore should throw" {
|
It "Missing CredentialStore should throw" {
|
||||||
{ New-CredentialStoreItem -Shared -Path 'C:\missingStore.json' -RemoteHost 'notrelevant' } | Should -Throw "Could not add anything"
|
{
|
||||||
|
New-CredentialStoreItem -Shared -Path '/tmp/missingStore.json' -RemoteHost 'notrelevant'
|
||||||
|
} | Should -Throw "The given credential store (/tmp/missingStore.json) does not exist!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Context "Testing pipeline paramter" {
|
Context "Testing pipeline paramter" {
|
||||||
It "Add the item with credential value from pipe" {
|
It "Add the item with credential value from pipe" {
|
||||||
$UserName = 'pipeUser'
|
$UserName = 'pipeUser'
|
||||||
$Password = ConvertTo-SecureString -String "pipePasswd" -AsPlainText -Force
|
$Password = ConvertTo-SecureString -String "pipePasswd" -AsPlainText -Force
|
||||||
{ [PSCredential]::new($UserName, $Password) | New-CredentialStoreItem -RemoteHost 'PipeHost' } | Should -Not -Throw
|
{
|
||||||
|
[PSCredential]::new($UserName, $Password) | New-CredentialStoreItem -RemoteHost 'PipeHost'
|
||||||
|
} | Should -Not -Throw
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Testing written item" {
|
It "Testing written item" {
|
||||||
@ -105,5 +142,4 @@ Describe "New-CredentialStoreItem" {
|
|||||||
$writtenItem.GetNetworkCredential().Password | Should -Be 'mypasswd'
|
$writtenItem.GetNetworkCredential().Password | Should -Be 'mypasswd'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -21,6 +21,10 @@ function New-CredentialStoreItem {
|
|||||||
.PARAMETER Credential
|
.PARAMETER Credential
|
||||||
You can provide credentials optionally as pre existing pscredential object.
|
You can provide credentials optionally as pre existing pscredential object.
|
||||||
|
|
||||||
|
.PARAMETER Shared
|
||||||
|
Define the CredentialStore where you want to add the new item. Default is always personal but can be
|
||||||
|
changed to shared, or even shared with custom path.
|
||||||
|
|
||||||
.INPUTS
|
.INPUTS
|
||||||
[None]
|
[None]
|
||||||
|
|
||||||
@ -28,27 +32,23 @@ function New-CredentialStoreItem {
|
|||||||
[None]
|
[None]
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
New-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
New-CredentialStoreItem -Path 'C:\TMP\mystore.json' -RemoteHost esx01.myside.local'
|
||||||
|
|
||||||
.NOTES
|
|
||||||
```
|
|
||||||
File Name : New-CredentialStoreItem.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
```
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||||
param(
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
'PSUseShouldProcessForStateChangingFunctions',
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
'',
|
||||||
|
Justification = 'Adds data into an existing object/file'
|
||||||
|
)]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||||
|
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$RemoteHost,
|
[string]$RemoteHost,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$Identifier,
|
[string]$Identifier,
|
||||||
|
|
||||||
@ -56,10 +56,10 @@ function New-CredentialStoreItem {
|
|||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[PSCredential]$Credential,
|
[PSCredential]$Credential,
|
||||||
|
|
||||||
[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()]
|
||||||
[string]$Path
|
[string]$Path
|
||||||
|
|
||||||
@ -68,11 +68,11 @@ function New-CredentialStoreItem {
|
|||||||
|
|
||||||
begin {
|
begin {
|
||||||
# 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
|
||||||
}
|
}
|
||||||
@ -84,28 +84,19 @@ function New-CredentialStoreItem {
|
|||||||
if (-not(Test-CredentialStore -Shared -Path $Path)) {
|
if (-not(Test-CredentialStore -Shared -Path $Path)) {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Exception = [System.IO.FileNotFoundException]::new(
|
Exception = [System.IO.FileNotFoundException]::new(
|
||||||
'Could not add anything into the given CredentialStore.'
|
'The given credential store ({0}) does not exist!' -f $Path
|
||||||
)
|
)
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
|
|
||||||
# Read the file content based on the given ParameterSetName
|
|
||||||
<#
|
|
||||||
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
|
||||||
$CSContent = Get-CredentialStore
|
|
||||||
}
|
|
||||||
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
|
||||||
$CSContent = Get-CredentialStore -Shared -Path $Path
|
|
||||||
}
|
|
||||||
#>
|
|
||||||
$CSContent = Get-CredentialStore -Shared -Path $Path
|
$CSContent = Get-CredentialStore -Shared -Path $Path
|
||||||
|
|
||||||
$CurrentDate = Get-Date -UFormat "%Y-%m-%d %H:%M:%S"
|
$CurrentDate = Get-Date -Format 'u'
|
||||||
|
|
||||||
if ($Identifier -ne "") {
|
if ($Identifier -ne '') {
|
||||||
$CredentialName = $RemoteHost = "{0}/{1}" -f $Identifier, $RemoteHost
|
$CredentialName = $RemoteHost = '{0}/{1}' -f $Identifier, $RemoteHost
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$CredentialName = $RemoteHost
|
$CredentialName = $RemoteHost
|
||||||
@ -116,37 +107,16 @@ function New-CredentialStoreItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($Credential.UserName) {
|
if ($Credential.UserName) {
|
||||||
try {
|
|
||||||
if ($null -eq $CSContent.PfxCertificate) {
|
if ($null -eq $CSContent.PfxCertificate) {
|
||||||
$Cert = Get-CSCertificate -Thumbprint $CSContent.Thumbprint
|
$Cert = Get-CSCertificate -Type $CSContent.Type -Thumbprint $CSContent.Thumbprint
|
||||||
if ($null -eq $Cert) {
|
|
||||||
$ErrorParams = @{
|
|
||||||
ErrorAction = 'Stop'
|
|
||||||
Exception = [System.Security.Cryptography.X509Certificates.FileNotFoundException]::new(
|
|
||||||
('Could not find the linked certificate with thumbprint {0}' -f $CSContent.Thumbprint)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Write-Error @ErrorParams
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$Cert = Get-PfxCertificate -FilePath $CSContent.PfxCertificate -ErrorAction Stop
|
$Cert = Get-PfxCertificate -FilePath $CSContent.PfxCertificate -ErrorAction Stop
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch {
|
|
||||||
$_.Exception.Message | Write-Error
|
|
||||||
$ErrorParams = @{
|
|
||||||
ErrorAction = 'Stop'
|
|
||||||
Exception = [System.Security.Cryptography.CryptographicException]::new(
|
|
||||||
'Could not read the given PFX certificate.'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Write-Error @ErrorParams
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Get-Member -InputObject $CSContent -Name $CredentialName -Membertype Properties) {
|
if (Get-Member -InputObject $CSContent -Name $CredentialName -MemberType Properties) {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "The given host already exists. Nothing to do here."
|
Message = 'The given host already exists. Nothing to do here.'
|
||||||
}
|
}
|
||||||
Write-Warning @MessageParams
|
Write-Warning @MessageParams
|
||||||
}
|
}
|
||||||
@ -158,16 +128,27 @@ function New-CredentialStoreItem {
|
|||||||
Password = ConvertFrom-SecureString -SecureString $Credential.Password -Key $RSAKey
|
Password = ConvertFrom-SecureString -SecureString $Credential.Password -Key $RSAKey
|
||||||
Created = $CurrentDate
|
Created = $CurrentDate
|
||||||
LastChange = $null
|
LastChange = $null
|
||||||
EncryptedKey = [Convert]::ToBase64String($Cert.PublicKey.Key.Encrypt($RSAKey, [System.Security.Cryptography.RSAEncryptionPadding]::Pkcs1))
|
EncryptedKey = [Convert]::ToBase64String(
|
||||||
|
$Cert.PublicKey.Key.Encrypt(
|
||||||
|
$RSAKey,
|
||||||
|
[System.Security.Cryptography.RSAEncryptionPadding]::Pkcs1
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Add-Member -InputObject $CSContent -Name $CredentialName -MemberType NoteProperty -Value $CredentialHash
|
$MemberParams = @{
|
||||||
|
InputObject = $CSContent
|
||||||
|
Name = $CredentialName
|
||||||
|
MemberType = 'NoteProperty'
|
||||||
|
Value = $CredentialHash
|
||||||
|
}
|
||||||
|
Add-Member @MemberParams
|
||||||
try {
|
try {
|
||||||
ConvertTo-Json -InputObject $CSContent | Out-File -FilePath $Path
|
ConvertTo-Json -InputObject $CSContent | Out-File -FilePath $Path
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Couldn't add item into credential store!"
|
Message = 'Could not add item into credential store!'
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -175,15 +156,13 @@ function New-CredentialStoreItem {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Please Provide at least a valid user!"
|
Message = 'Please Provide at least a valid user!'
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,32 +37,27 @@ function Remove-CredentialStoreItem {
|
|||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Remove-CredentialStoreItem -RemoteHost "esx01.myside.local" -Identifier svc
|
Remove-CredentialStoreItem -RemoteHost "esx01.myside.local" -Identifier svc
|
||||||
|
|
||||||
.NOTES
|
|
||||||
```
|
|
||||||
File Name : Remove-CredentialStoreItem.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
```
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||||
param(
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
'PSUseShouldProcessForStateChangingFunctions',
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
'',
|
||||||
|
Justification = 'Removes data from existing store.'
|
||||||
|
)]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||||
|
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||||
[string]$RemoteHost,
|
[string]$RemoteHost,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||||
[string]$Identifier,
|
[string]$Identifier,
|
||||||
|
|
||||||
[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()]
|
||||||
[string]$Path
|
[string]$Path
|
||||||
)
|
)
|
||||||
@ -70,10 +65,10 @@ function Remove-CredentialStoreItem {
|
|||||||
begin {
|
begin {
|
||||||
# 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
|
||||||
}
|
}
|
||||||
@ -84,8 +79,8 @@ function Remove-CredentialStoreItem {
|
|||||||
# Lets do a quick test on the given CredentialStore.
|
# Lets do a quick test on the given CredentialStore.
|
||||||
if (-not(Test-CredentialStore -Shared -Path $Path)) {
|
if (-not(Test-CredentialStore -Shared -Path $Path)) {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Could not add anything into the given CredentialStore."
|
Message = 'Could not add anything into the given CredentialStore.'
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
@ -100,14 +95,14 @@ function Remove-CredentialStoreItem {
|
|||||||
$CredentialName = $RemoteHost
|
$CredentialName = $RemoteHost
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Get-Member -InputObject $CSContent -Name $CredentialName -Membertype NoteProperty) {
|
if (Get-Member -InputObject $CSContent -Name $CredentialName -MemberType NoteProperty) {
|
||||||
# We need to use the .NET Method because there is no easier way in PowerShell.
|
# We need to use the .NET Method because there is no easier way in PowerShell.
|
||||||
$CSContent.PSObject.Properties.Remove($CredentialName)
|
$CSContent.PSObject.Properties.Remove($CredentialName)
|
||||||
ConvertTo-Json -InputObject $CSContent -Depth 5 | Out-File -FilePath $Path -Encoding utf8
|
ConvertTo-Json -InputObject $CSContent -Depth 5 | Out-File -FilePath $Path -Encoding utf8
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "The given CredentialStoreItem does not exist."
|
Message = 'The given CredentialStoreItem does not exist.'
|
||||||
}
|
}
|
||||||
Write-Warning @MessageParams
|
Write-Warning @MessageParams
|
||||||
}
|
}
|
||||||
|
130
src/Item/Set-CredentialStoreItem.Tests.ps1
Normal file
130
src/Item/Set-CredentialStoreItem.Tests.ps1
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
|
'PSAvoidUsingConvertToSecureStringWithPlainText',
|
||||||
|
'',
|
||||||
|
Justification = 'just used in pester tests.'
|
||||||
|
)]
|
||||||
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
|
'PSProvideCommentHelp',
|
||||||
|
'',
|
||||||
|
Justification = 'no need in internal pester helpers.'
|
||||||
|
)]
|
||||||
|
param ()
|
||||||
|
|
||||||
|
BeforeAll {
|
||||||
|
$ManifestFile = (Get-Item -Path './src/*.psd1').FullName
|
||||||
|
Import-Module $ManifestFile -Force
|
||||||
|
|
||||||
|
$PrivateFunctions = (Get-ChildItem -Path './src/Private/*.ps1' | Where-Object {
|
||||||
|
$_.BaseName -notmatch '.Tests'
|
||||||
|
}
|
||||||
|
).FullName
|
||||||
|
foreach ( $func in $PrivateFunctions) {
|
||||||
|
. $func
|
||||||
|
}
|
||||||
|
|
||||||
|
# Backup existing credential stores
|
||||||
|
$VerbosePreference = 'Continue'
|
||||||
|
Write-Verbose -Message 'Backup private Credential Store...'
|
||||||
|
$CSPath = Get-DefaultCredentialStorePath
|
||||||
|
$BackupFile = '{0}.back' -f $CSPath
|
||||||
|
if (Test-Path -Path $CSPath) {
|
||||||
|
Move-Item -Path $CSPath -Destination $BackupFile
|
||||||
|
}
|
||||||
|
Write-Verbose -Message 'Backup shared CredentialStore...'
|
||||||
|
$CSShared = Get-DefaultCredentialStorePath -Shared
|
||||||
|
$BackupSharedFile = '{0}.back' -f $CSShared
|
||||||
|
if (Test-Path -Path $CSShared) {
|
||||||
|
Move-Item -Path $CSShared -Destination $BackupSharedFile
|
||||||
|
}
|
||||||
|
Write-Verbose -Message 'Remove old CredentialStore in Temp dir'
|
||||||
|
$CSTemp = Join-Path -Path (Get-TempDir) -ChildPath '/CredentialStore.json'
|
||||||
|
if (Test-Path -Path $CSTemp) {
|
||||||
|
Remove-Item -Path $CSTemp
|
||||||
|
}
|
||||||
|
$VerbosePreference = 'SilentlyContinue'
|
||||||
|
}
|
||||||
|
|
||||||
|
Describe 'New-CredentialStoreItem' {
|
||||||
|
Context 'Private Credential Store tests' {
|
||||||
|
It 'Add entry to a private store.' {
|
||||||
|
# Create a fresh CredentialStore first
|
||||||
|
New-CredentialStore -Force
|
||||||
|
|
||||||
|
# Define the content of the CredentialStoreItem.
|
||||||
|
$RemoteHost = 'barfoo'
|
||||||
|
$UserName = 'MyUser'
|
||||||
|
$Password = 'fooobarysdfsfs' | ConvertTo-SecureString -AsPlainText -Force
|
||||||
|
|
||||||
|
# Form the CredentialObject.
|
||||||
|
$creds = [PSCredential]::new($UserName, $Password)
|
||||||
|
|
||||||
|
# Create the CredentialStoreItem.
|
||||||
|
New-CredentialStoreItem -RemoteHost $RemoteHost -Credential $creds
|
||||||
|
|
||||||
|
# Formulate an update to the CredentialStoreItem.
|
||||||
|
$ClearPassword = 'fooobaryadfafa'
|
||||||
|
$Password = $ClearPassword | ConvertTo-SecureString -AsPlainText -Force
|
||||||
|
$creds = [PSCredential]::new($UserName, $Password)
|
||||||
|
{
|
||||||
|
Set-CredentialStoreItem -RemoteHost $RemoteHost -Credential $creds
|
||||||
|
} | Should -Not -Throw
|
||||||
|
|
||||||
|
# Control the content of the CredentialStore.
|
||||||
|
$content = Get-CredentialStoreItem -RemoteHost $RemoteHost
|
||||||
|
$content.GetNetworkCredential().Password | Should -Be $ClearPassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Context 'Shared Credential Store tests' {
|
||||||
|
It 'Add entry to a shared store.' {
|
||||||
|
# Create a fresh CredentialStore first
|
||||||
|
$tmpCS = Join-Path -Path (Get-TempDir) -ChildPath '/CredentialStore.json'
|
||||||
|
New-CredentialStore -Path $tmpCS -Force -Shared
|
||||||
|
|
||||||
|
# Define the content of the CredentialStoreItem.
|
||||||
|
$RemoteHost = 'barfoo'
|
||||||
|
$UserName = 'MyUser'
|
||||||
|
$Password = 'fooobarysdfsfs' | ConvertTo-SecureString -AsPlainText -Force
|
||||||
|
|
||||||
|
# Form the CredentialObject.
|
||||||
|
$creds = [PSCredential]::new($UserName, $Password)
|
||||||
|
|
||||||
|
# Create the CredentialStoreItem.
|
||||||
|
New-CredentialStoreItem -RemoteHost $RemoteHost -Credential $creds -Path $tmpCS -Shared
|
||||||
|
|
||||||
|
# Formulate an update to the CredentialStoreItem.
|
||||||
|
$ClearPassword = 'fooobaryadfafa'
|
||||||
|
$Password = $ClearPassword | ConvertTo-SecureString -AsPlainText -Force
|
||||||
|
$creds = [PSCredential]::new($UserName, $Password)
|
||||||
|
|
||||||
|
{
|
||||||
|
Set-CredentialStoreItem -RemoteHost $RemoteHost -Credential $creds -Path $tmpCS -Shared
|
||||||
|
} | Should -Not -Throw
|
||||||
|
|
||||||
|
# Control the content of the CredentialStore.
|
||||||
|
$content = Get-CredentialStoreItem -RemoteHost $RemoteHost -Path $tmpCS -Shared
|
||||||
|
$content.GetNetworkCredential().Password | Should -Be $ClearPassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AfterAll {
|
||||||
|
# Cleanup test stores and restore existing ones.
|
||||||
|
$VerbosePreference = 'Continue'
|
||||||
|
Write-Verbose -Message 'Restoring private CredentialStore'
|
||||||
|
If (Test-Path -Path $BackupFile) {
|
||||||
|
If (Test-Path -Path $CSPath) {
|
||||||
|
Remove-Item -Path $CSPath
|
||||||
|
Move-Item -Path $BackupFile -Destination $CSPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Verbose -Message 'Restoring shared CredentialStore'
|
||||||
|
If (Test-Path -Path $BackupSharedFile) {
|
||||||
|
If (Test-Path -Path $CSShared) {
|
||||||
|
Remove-Item -Path $CSShared
|
||||||
|
Move-Item -Path $BackupSharedFile -Destination $CSShared
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$VerbosePreference = 'SilentlyContinue'
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@ function Set-CredentialStoreItem {
|
|||||||
Changes the credentials for the given remote host in the store.
|
Changes the credentials for the given remote host in the store.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
|
Use this function to update your already stored RemoteHost items.
|
||||||
|
|
||||||
.PARAMETER Path
|
.PARAMETER Path
|
||||||
Define the store in which your given host entry already exists.
|
Define the store in which your given host entry already exists.
|
||||||
@ -12,13 +13,16 @@ function Set-CredentialStoreItem {
|
|||||||
Specify the host you for which you would like to change the credentials.
|
Specify the host you for which you would like to change the credentials.
|
||||||
|
|
||||||
.PARAMETER Identifier
|
.PARAMETER Identifier
|
||||||
Defaults to "". Specify a string, which separates two CredentialStoreItems for the
|
Defaults to ''. Specify a string, which separates two CredentialStoreItems for the
|
||||||
same hostname.
|
same hostname.
|
||||||
|
|
||||||
.PARAMETER Shared
|
.PARAMETER Shared
|
||||||
Switch to shared mode with this param. This enforces the command to work with a shared CredentialStore which
|
Switch to shared mode with this param. This enforces the command to work with a shared CredentialStore which
|
||||||
can be decrypted across systems.
|
can be decrypted across systems.
|
||||||
|
|
||||||
|
.PARAMETER Credential
|
||||||
|
Provided the new credentials you want to update inside the RemoteHost item.
|
||||||
|
|
||||||
.INPUTS
|
.INPUTS
|
||||||
[None]
|
[None]
|
||||||
|
|
||||||
@ -26,49 +30,46 @@ function Set-CredentialStoreItem {
|
|||||||
[None]
|
[None]
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Set-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
Set-CredentialStoreItem -Path 'C:\TMP\mystore.json' -RemoteHost 'esx01.myside.local'
|
||||||
Set-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local" -Identifier svc
|
|
||||||
|
|
||||||
.NOTES
|
.EXAMPLE
|
||||||
```
|
Set-CredentialStoreItem -Path 'C:\TMP\mystore.json' -RemoteHost 'esx01.myside.local' -Identifier svc
|
||||||
File Name : Set-CredentialStoreItem.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
```
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||||
param(
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
'PSUseShouldProcessForStateChangingFunctions',
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
'',
|
||||||
|
Justification = 'Updates existing credential object.'
|
||||||
|
)]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||||
|
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||||
[string]$RemoteHost,
|
[string]$RemoteHost,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||||
[string]$Identifier,
|
[string]$Identifier,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false, ValueFromPipeline = $true)]
|
[Parameter(Mandatory = $false, ValueFromPipeline = $true)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[PSCredential]$Credential,
|
[PSCredential]$Credential,
|
||||||
|
|
||||||
[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()]
|
||||||
[string]$Path
|
[string]$Path
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
# 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
|
||||||
}
|
}
|
||||||
@ -76,55 +77,71 @@ function Set-CredentialStoreItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
# Lets do a quick test on the given CredentialStore.
|
# Define the default splatting.
|
||||||
if (-not(Test-CredentialStore -Shared -Path $Path)) {
|
$DefaultSplatting = @{
|
||||||
|
Path = $Path
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if the user passed -Shared. If he added -Shared, we'll pass it into the splatting
|
||||||
|
if ($PSBoundParameters.ContainsKey('Shared')) {
|
||||||
|
$DefaultSplatting.Add('Shared', $true)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$DefaultSplatting.Add('Shared', $false)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Now lets check the given CredentialStore.
|
||||||
|
if (-not(Test-CredentialStore @DefaultSplatting)) {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Could not add anything into the given CredentailStore."
|
Message = ('The given CredentialStore ({0}) does no exist.' -f $Path)
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
|
|
||||||
# Read the file content based on the given ParameterSetName
|
# Read the file content based on the given ParameterSetName
|
||||||
$CSContent = Get-CredentialStore -Shared -Path $Path
|
$CSContent = Get-CredentialStore @DefaultSplatting
|
||||||
|
|
||||||
$CurrentDate = Get-Date -UFormat "%Y-%m-%d %H:%M:%S"
|
# Get a formatted current date for the last update time of the Item.
|
||||||
|
$CurrentDate = Get-Date -Format 'u'
|
||||||
|
|
||||||
if ($Identifier -ne "") {
|
# Check if the user supplied an identifier. If so, we need to mangle the CredentialName, as that's where
|
||||||
$CredentialName = $RemoteHost = "{0}/{1}" -f $Identifier, $RemoteHost
|
# the identifier is actually added.
|
||||||
|
if ($Identifier -ne '') {
|
||||||
|
$CredentialName = $RemoteHost = '{0}/{1}' -f $Identifier, $RemoteHost
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$CredentialName = $RemoteHost
|
$CredentialName = $RemoteHost
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# If the user didn't supply a CredentialObject, we need to prompt for it.
|
||||||
if (-not($Credential)) {
|
if (-not($Credential)) {
|
||||||
$Credential = Get-Credential -Message $CredentialName
|
$Credential = Get-Credential -Message $CredentialName
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Credential.UserName) {
|
# If the username isn't empty, we ca go ahead and update the entry.
|
||||||
try {
|
if ($null -ne $Credential.UserName -and -not [string]::IsNullOrWhiteSpace($Credential.UserName)) {
|
||||||
|
# Check if the path to the PfxCertificate is stored in the CredentialStore. If so load the certificate.
|
||||||
|
# If not, load try loading the certificate from the Filepath of the CredentialStore.
|
||||||
if ($null -eq $CSContent.PfxCertificate) {
|
if ($null -eq $CSContent.PfxCertificate) {
|
||||||
$Cert = Get-CSCertificate -Thumbprint $CSContent.Thumbprint
|
$Cert = Get-CSCertificate -Type $CSContent.Type -Thumbprint $CSContent.Thumbprint
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$Cert = Get-PfxCertificate -FilePath $CSContent.PfxCertificate -ErrorAction Stop
|
$Cert = Get-PfxCertificate -FilePath $CSContent.PfxCertificate -ErrorAction Stop
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch {
|
|
||||||
$_.Exception.Message | Write-Error
|
|
||||||
$ErrorParams = @{
|
|
||||||
ErrorAction = 'Stop'
|
|
||||||
Exception = [System.Security.Cryptography.CryptographicException]::new(
|
|
||||||
'Could not read the given PFX certificate.'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Write-Error @ErrorParams
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Get-Member -InputObject $CSContent -Name $CredentialName -Membertype Properties) {
|
# Now locate the Item.
|
||||||
|
if (Get-Member -InputObject $CSContent -Name $CredentialName -MemberType Properties) {
|
||||||
|
# Get a random AES key for the entry.
|
||||||
$RSAKey = Get-RandomAESKey
|
$RSAKey = Get-RandomAESKey
|
||||||
$CSContent.$CredentialName.User = $Credential.UserName
|
$CSContent.$CredentialName.User = $Credential.UserName
|
||||||
$CSContent.$CredentialName.Password = ConvertFrom-SecureString -SecureString $Credential.Password -Key $RSAKey
|
$ConvertParams = @{
|
||||||
|
SecureString = $Credential.Password
|
||||||
|
Key = $RSAKey
|
||||||
|
}
|
||||||
|
|
||||||
|
# Now create a updated item containing the updated credentials.
|
||||||
|
$CSContent.$CredentialName.Password = ConvertFrom-SecureString @ConvertParams
|
||||||
$CSContent.$CredentialName.LastChange = $CurrentDate
|
$CSContent.$CredentialName.LastChange = $CurrentDate
|
||||||
$CSContent.$CredentialName.EncryptedKey = [Convert]::ToBase64String(
|
$CSContent.$CredentialName.EncryptedKey = [Convert]::ToBase64String(
|
||||||
$Cert.PublicKey.Key.Encrypt(
|
$Cert.PublicKey.Key.Encrypt(
|
||||||
@ -132,13 +149,18 @@ function Set-CredentialStoreItem {
|
|||||||
[System.Security.Cryptography.RSAEncryptionPadding]::Pkcs1
|
[System.Security.Cryptography.RSAEncryptionPadding]::Pkcs1
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Convert the CredentialStore back into JSON and save it to the file.
|
||||||
ConvertTo-Json -InputObject $CSContent -Depth 5 | Out-File -FilePath $Path -Encoding utf8
|
ConvertTo-Json -InputObject $CSContent -Depth 5 | Out-File -FilePath $Path -Encoding utf8
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Write-Warning -Message ('Unable to locate CredentialStoreItem for {0}' -f $CredentialName)
|
||||||
}
|
}
|
||||||
Else {
|
}
|
||||||
|
else {
|
||||||
$MessageParams = @{
|
$MessageParams = @{
|
||||||
Message = "Please Provide at least a valid user!"
|
Message = 'Please Provide at least a valid user!'
|
||||||
ErrorAction = "Stop"
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
Write-Error @MessageParams
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,10 @@ function Test-CredentialStoreItem {
|
|||||||
Use this cmdlet for basic checks with a single item. Check the item first with this function before
|
Use this cmdlet for basic checks with a single item. Check the item first with this function before
|
||||||
you try to interact with it.
|
you try to interact with it.
|
||||||
|
|
||||||
|
Breaking Change for `v1.1.0+`:
|
||||||
|
Test-CredentialStoreItem will return `$false` even if the store doesn't exist. We removed the terminating
|
||||||
|
error and replaced it with a warning message.
|
||||||
|
|
||||||
.PARAMETER Path
|
.PARAMETER Path
|
||||||
Define a custom credential store you try to read from. Without the `-Path` parameter
|
Define a custom credential store you try to read from. Without the `-Path` parameter
|
||||||
`Test-CredentialStoreItem` tries to read from the default private store.
|
`Test-CredentialStoreItem` tries to read from the default private store.
|
||||||
@ -29,28 +33,19 @@ function Test-CredentialStoreItem {
|
|||||||
[None]
|
[None]
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
If (Test-CredentialStoreItem -RemoteHost "Default") {
|
if (Test-CredentialStoreItem -RemoteHost 'Default') {
|
||||||
Get-CredentialStoreItem -RemoteHost "Default"
|
Get-CredentialStoreItem -RemoteHost 'Default'
|
||||||
}
|
}
|
||||||
Else {
|
else {
|
||||||
Write-Warning ("The given Remote Host {0} does not exist in the credential Store!" -f $RemoteHost)
|
Write-Warning ('The given Remote Host {0} does not exist in the credential Store!' -f $RemoteHost)
|
||||||
}
|
}
|
||||||
|
|
||||||
.NOTES
|
|
||||||
```
|
|
||||||
File Name : Test-CredentialStoreItem.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
```
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
|
||||||
[OutputType([Boolean])]
|
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||||
param(
|
[OutputType([bool])]
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
param (
|
||||||
[string]$Path = "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData,
|
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||||
|
[string]$Path = '{0}\PSCredentialStore\CredentialStore.json' -f $env:ProgramData,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
@ -60,17 +55,17 @@ function Test-CredentialStoreItem {
|
|||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$Identifier,
|
[string]$Identifier,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||||
[switch]$Shared
|
[switch]$Shared
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
# 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
|
||||||
}
|
}
|
||||||
@ -78,8 +73,8 @@ function Test-CredentialStoreItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
if ($Identifier -ne "") {
|
if ($Identifier -ne '') {
|
||||||
$CredentialName = $RemoteHost = "{0}/{1}" -f $Identifier, $RemoteHost
|
$CredentialName = $RemoteHost = '{0}/{1}' -f $Identifier, $RemoteHost
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$CredentialName = $RemoteHost
|
$CredentialName = $RemoteHost
|
||||||
@ -88,7 +83,7 @@ function Test-CredentialStoreItem {
|
|||||||
if (Test-CredentialStore -Shared -Path $Path) {
|
if (Test-CredentialStore -Shared -Path $Path) {
|
||||||
$CS = Get-CredentialStore -Shared -Path $Path
|
$CS = Get-CredentialStore -Shared -Path $Path
|
||||||
$CSMembers = Get-Member -InputObject $CS
|
$CSMembers = Get-Member -InputObject $CS
|
||||||
if (($CSMembers.MemberType -eq "NoteProperty") -and ($CSMembers.Name -contains $CredentialName)) {
|
if (($CSMembers.MemberType -eq 'NoteProperty') -and ($CSMembers.Name -contains $CredentialName)) {
|
||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -97,15 +92,13 @@ function Test-CredentialStoreItem {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$MsgParams = @{
|
$MsgParams = @{
|
||||||
ErrorAction = "Stop"
|
Message = 'The given credential store ({0}) does not exist!' -f $Path
|
||||||
Message = "The given credential store ({0}) does not exist!" -f $Path
|
|
||||||
}
|
}
|
||||||
Write-Error @MsgParams
|
Write-Warning @MsgParams
|
||||||
|
return $false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
11
src/ModuleRoot.psm1
Normal file
11
src/ModuleRoot.psm1
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#region module-definition
|
||||||
|
|
||||||
|
#endregion module-definition
|
||||||
|
Set-Variable -Name "CSVersion" -Value "2.0.0" -Option Constant -Scope 'Script' -ErrorAction Stop
|
||||||
|
|
||||||
|
# Get all child items in the Script path and exclude the Deploy script (if present.)
|
||||||
|
$Functions = Get-ChildItem -Path $PSScriptRoot\*.ps1 -Recurse | Where-Object { $_.BaseName -notmatch '.Tests' }
|
||||||
|
|
||||||
|
foreach ($Item in $Functions) {
|
||||||
|
. $Item.FullName
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
@{
|
@{
|
||||||
|
|
||||||
# Script module or binary module file associated with this manifest.
|
# Script module or binary module file associated with this manifest.
|
||||||
RootModule = 'PSCredentialStore.psm1'
|
RootModule = 'ModuleRoot.psm1'
|
||||||
|
|
||||||
# Version number of this module.
|
# Version number of this module.
|
||||||
ModuleVersion = '0.0.9999'
|
ModuleVersion = '0.0.9999'
|
||||||
@ -19,10 +19,10 @@
|
|||||||
CompanyName = ''
|
CompanyName = ''
|
||||||
|
|
||||||
# Copyright statement for this module
|
# Copyright statement for this module
|
||||||
Copyright = '(c) 2019 OCram85. All rights reserved.'
|
Copyright = '(c) OCram85. All rights reserved.'
|
||||||
|
|
||||||
# Description of the functionality provided by this module
|
# Description of the functionality provided by this module
|
||||||
Description = 'A simple credential manager to store and reuse multiple credential objects.'
|
Description = 'A simple cross-platform credential manager for PSCredential objects.'
|
||||||
|
|
||||||
# Minimum version of the PowerShell engine required by this module
|
# Minimum version of the PowerShell engine required by this module
|
||||||
PowerShellVersion = '5.1'
|
PowerShellVersion = '5.1'
|
||||||
@ -33,10 +33,12 @@
|
|||||||
# Minimum version of the PowerShell host required by this module
|
# Minimum version of the PowerShell host required by this module
|
||||||
# PowerShellHostVersion = ''
|
# PowerShellHostVersion = ''
|
||||||
|
|
||||||
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
|
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the
|
||||||
|
# PowerShell Desktop edition only.
|
||||||
# DotNetFrameworkVersion = ''
|
# DotNetFrameworkVersion = ''
|
||||||
|
|
||||||
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
|
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for
|
||||||
|
# the PowerShell Desktop edition only.
|
||||||
# CLRVersion = ''
|
# CLRVersion = ''
|
||||||
|
|
||||||
# Processor architecture (None, X86, Amd64) required by this module
|
# Processor architecture (None, X86, Amd64) required by this module
|
||||||
@ -55,20 +57,28 @@
|
|||||||
# TypesToProcess = @()
|
# TypesToProcess = @()
|
||||||
|
|
||||||
# Format files (.ps1xml) to be loaded when importing this module
|
# Format files (.ps1xml) to be loaded when importing this module
|
||||||
# FormatsToProcess = @()
|
FormatsToProcess = @(
|
||||||
|
'Formats/PSCredential.Store.Format.ps1xml',
|
||||||
|
'Formats/PSCredentialStore.Certificate.Attribute.ps1xml'
|
||||||
|
)
|
||||||
|
|
||||||
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
|
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
|
||||||
# NestedModules = @()
|
# NestedModules = @()
|
||||||
|
|
||||||
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
|
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry,
|
||||||
|
# use an empty array if there are no functions to export.
|
||||||
FunctionsToExport = @(
|
FunctionsToExport = @(
|
||||||
# Certificate
|
# Certificate
|
||||||
'Get-CSCertificate',
|
'Get-CSCertificate',
|
||||||
'Import-CSCertificate',
|
'Import-CSCertificate',
|
||||||
'New-CRTAttribute',
|
'New-CSCertAttribute',
|
||||||
'New-PfxCertificate',
|
'New-CSCertificate',
|
||||||
'Test-CSCertificate',
|
'Test-CSCertificate',
|
||||||
'Use-PfxCertificate',
|
'Use-CSCertificate',
|
||||||
|
# Pfx Certificate
|
||||||
|
# 'Get-CSPfxCertificate',
|
||||||
|
# 'Import-CSPfxCertificate',
|
||||||
|
# 'Test-CSPfxCertificate',
|
||||||
# Connection
|
# Connection
|
||||||
'Connect-To',
|
'Connect-To',
|
||||||
'Disconnect-From',
|
'Disconnect-From',
|
||||||
@ -85,13 +95,15 @@
|
|||||||
'Test-CredentialStore'
|
'Test-CredentialStore'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
|
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry,
|
||||||
|
# use an empty array if there are no cmdlets to export.
|
||||||
CmdletsToExport = @()
|
CmdletsToExport = @()
|
||||||
|
|
||||||
# Variables to export from this module
|
# Variables to export from this module
|
||||||
VariablesToExport = '*'
|
VariablesToExport = '*'
|
||||||
|
|
||||||
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
|
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry,
|
||||||
|
# use an empty array if there are no aliases to export.
|
||||||
AliasesToExport = @()
|
AliasesToExport = @()
|
||||||
|
|
||||||
# DSC resources to export from this module
|
# DSC resources to export from this module
|
||||||
@ -103,7 +115,8 @@
|
|||||||
# List of all files packaged with this module
|
# List of all files packaged with this module
|
||||||
# FileList = @()
|
# FileList = @()
|
||||||
|
|
||||||
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
|
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData
|
||||||
|
# hashtable with additional module metadata used by PowerShell.
|
||||||
PrivateData = @{
|
PrivateData = @{
|
||||||
|
|
||||||
PSData = @{
|
PSData = @{
|
||||||
@ -112,34 +125,60 @@
|
|||||||
Tags = 'CredentialStore', 'CredentialManager'
|
Tags = 'CredentialStore', 'CredentialManager'
|
||||||
|
|
||||||
# A URL to the license for this module.
|
# A URL to the license for this module.
|
||||||
LicenseUri = 'https://github.com/OCram85/PSCredentialStore/blob/master/LICENSE'
|
LicenseUri = 'https://gitea.ocram85.com/OCram85/PSCredentialStore/raw/branch/master/LICENSE'
|
||||||
|
|
||||||
# A URL to the main website for this project.
|
# A URL to the main website for this project.
|
||||||
ProjectUri = 'https://github.com/OCram85/PSCredentialStore'
|
ProjectUri = 'https://gitea.ocram85.com/OCram85/PSCredentialStore'
|
||||||
|
|
||||||
# A URL to an icon representing this module.
|
# A URL to an icon representing this module.
|
||||||
IconUri = 'https://raw.githubusercontent.com/OCram85/PSCredentialStore/master/assets/logo256.png'
|
IconUri = 'https://gitea.ocram85.com/OCram85/PSCredentialStore/raw/branch/master/assets/logo256.png'
|
||||||
|
|
||||||
# ReleaseNotes of this module
|
# ReleaseNotes of this module
|
||||||
ReleaseNotes = 'This is a pre-release version!. Do not use in production!'
|
ReleaseNotes = 'See https://gitea.ocram85.com/OCram85/PSCredentialStore/releases page for details.'
|
||||||
|
|
||||||
# Prerelease string of this module
|
# Prerelease string of this module
|
||||||
Prerelease = 'preview'
|
#Prerelease = 'preview'
|
||||||
|
|
||||||
# Flag to indicate whether the module requires explicit user acceptance for install/update
|
# Flag to indicate whether the module requires explicit user acceptance for install/update
|
||||||
# RequireLicenseAcceptance = $false
|
# RequireLicenseAcceptance = $false
|
||||||
|
|
||||||
# External dependent modules of this module
|
# External dependent modules of this module
|
||||||
# ExternalModuleDependencies = @()
|
ExternalModuleDependencies = @(
|
||||||
|
@{
|
||||||
|
ModuleName = 'VMware.VimAutomation.Core'
|
||||||
|
ModuleVersion = '12.7.0.20091293'
|
||||||
|
},
|
||||||
|
@{
|
||||||
|
ModuleName = 'VMware.VimAutomation.Cis.Core'
|
||||||
|
ModuleVersion = '12.6.0.19601368'
|
||||||
|
},
|
||||||
|
@{
|
||||||
|
ModuleName = 'Cisco.UCS.Common'
|
||||||
|
ModuleVersion = '3.0.1.2'
|
||||||
|
},
|
||||||
|
@{
|
||||||
|
ModuleName = 'Cisco.UCSManager'
|
||||||
|
ModuleVersion = '3.0.1.2'
|
||||||
|
},
|
||||||
|
@{
|
||||||
|
ModuleName = 'WinSCP'
|
||||||
|
ModuleVersion = '5.17.8.1'
|
||||||
|
},
|
||||||
|
@{
|
||||||
|
ModuleName = 'NetApp.ONTAP'
|
||||||
|
ModuleVersion = '9.10.1.2111'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
} # End of PSData hashtable
|
} # End of PSData hashtable
|
||||||
|
|
||||||
} # End of PrivateData hashtable
|
} # End of PrivateData hashtable
|
||||||
|
|
||||||
# HelpInfo URI of this module
|
# HelpInfo URI of this module
|
||||||
HelpInfoURI = 'https://github.com/OCram85/PSCredentialStore'
|
HelpInfoURI = 'https://gitea.ocram85.com/OCram85/PSCredentialStore'
|
||||||
|
|
||||||
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
|
# Default prefix for commands exported from this module. Override the default prefix
|
||||||
|
# using Import-Module -Prefix.
|
||||||
# DefaultCommandPrefix = ''
|
# DefaultCommandPrefix = ''
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
#region module-definition
|
|
||||||
|
|
||||||
#endregion module-definition
|
|
||||||
Set-Variable -Name "CSVersion" -Value "2.0.0" -Option Constant -Scope 'Script' -ErrorAction Stop
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region dot-sourcing
|
|
||||||
# dot-sourcing all module functions. The export is handled via manifest file.
|
|
||||||
|
|
||||||
$Items = (Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath '*.ps1') -Recurse ).FullName | Where-Object {
|
|
||||||
$_ -notmatch "(Classes|Init)"
|
|
||||||
}
|
|
||||||
foreach ($Item in $Items) {
|
|
||||||
# Write-Verbose ("dot sourcing file {0}" -f $Item)
|
|
||||||
. $Item
|
|
||||||
}
|
|
||||||
#endregion dot-sourcing
|
|
12
src/PSModule.Tests.ps1
Normal file
12
src/PSModule.Tests.ps1
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
Describe 'Test module meta' {
|
||||||
|
Context 'Default tests' -Tag 'Default' {
|
||||||
|
It 'Test manifest file' {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
Test-ModuleManifest -Path $ManifestFile | Should -Be $true
|
||||||
|
}
|
||||||
|
It 'Import Module' {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
{ Import-Module $ManifestFile } | Should -Not -Throw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
74
src/Private/Get-CSPfxCertificate.ps1
Normal file
74
src/Private/Get-CSPfxCertificate.ps1
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
function Get-CSPfxCertificate {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Returns the certificate object given by thumbprint.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
You can use this function to get a stored certificate. Search for the object by its unique thumbprint.
|
||||||
|
|
||||||
|
.PARAMETER Thumbprint
|
||||||
|
Provide one or more thumbprints.
|
||||||
|
|
||||||
|
.PARAMETER StoreName
|
||||||
|
Select the store name in which you want to search the certificates.
|
||||||
|
|
||||||
|
.PARAMETER StoreLocation
|
||||||
|
Select between the both available locations CurrentUser odr LocalMachine.
|
||||||
|
|
||||||
|
.INPUTS
|
||||||
|
[string]
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
[System.Security.Cryptography.X509Certificates.X509Certificate2[]]
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-CSPfxCertificate -Thumbprint '12345678' -StoreName 'My' -StoreLocation 'CurrentUser'
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
[OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2])]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string[]]$Thumbprint,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateSet(
|
||||||
|
'AddressBook',
|
||||||
|
'AuthRoot',
|
||||||
|
'CertificateAuthority',
|
||||||
|
'Disallowed',
|
||||||
|
'My',
|
||||||
|
'Root',
|
||||||
|
'TrustedPeople',
|
||||||
|
'TrustedPublisher'
|
||||||
|
)]
|
||||||
|
[string]$StoreName = 'My',
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateSet(
|
||||||
|
'CurrentUser',
|
||||||
|
'LocalMachine'
|
||||||
|
)]
|
||||||
|
[string]$StoreLocation = 'CurrentUser'
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
$Store = [System.Security.Cryptography.X509Certificates.X509Store]::New($StoreName, $StoreLocation)
|
||||||
|
try {
|
||||||
|
$Store.Open('ReadOnly')
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$_.Exception.Message | Write-Error -ErrorAction Stop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
foreach ($Thumb in $Thumbprint) {
|
||||||
|
Write-Output $Store.Certificates | Where-Object { $_.Thumbprint -eq $Thumb }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end {
|
||||||
|
$Store.Close()
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,16 @@
|
|||||||
|
BeforeAll {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
Import-Module $ManifestFile -Force
|
||||||
|
|
||||||
|
$PrivateFunctions = (Get-ChildItem -Path "./src/Private/*.ps1" | Where-Object {
|
||||||
|
$_.BaseName -notmatch '.Tests'
|
||||||
|
}
|
||||||
|
).FullName
|
||||||
|
foreach ( $func in $PrivateFunctions) {
|
||||||
|
. $func
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Describe "Get-DefaultCredentialStorePath" {
|
Describe "Get-DefaultCredentialStorePath" {
|
||||||
Context "Basic syntax test" {
|
Context "Basic syntax test" {
|
||||||
It "Test1: Should not throw" {
|
It "Test1: Should not throw" {
|
@ -14,18 +14,11 @@ function Get-DefaultCredentialStorePath {
|
|||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
$Path = Get-DefaultCredentialStorePath
|
$Path = Get-DefaultCredentialStorePath
|
||||||
|
|
||||||
.NOTES
|
|
||||||
File Name : Get-DefaultCredentialStorePath.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([string])]
|
[OutputType([string])]
|
||||||
param(
|
param (
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[switch]$Shared
|
[switch]$Shared
|
||||||
)
|
)
|
||||||
@ -40,7 +33,11 @@ function Get-DefaultCredentialStorePath {
|
|||||||
if ($IsMacOS) {
|
if ($IsMacOS) {
|
||||||
return Join-Path -Path '/var/opt' -ChildPath 'PSCredentialStore/CredentialStore.json'
|
return Join-Path -Path '/var/opt' -ChildPath 'PSCredentialStore/CredentialStore.json'
|
||||||
}
|
}
|
||||||
elseif (($isWindows) -or ($PSVersionTable.PSVersion.Major -lt 6) -or ($PSVersionTable.PSEdition -eq 'Desktop')) {
|
elseif (
|
||||||
|
($isWindows) -or
|
||||||
|
($PSVersionTable.PSVersion.Major -lt 6) -or
|
||||||
|
($PSVersionTable.PSEdition -eq 'Desktop')
|
||||||
|
) {
|
||||||
return Join-Path -Path $env:ProgramData -ChildPath 'PSCredentialStore/CredentialStore.json'
|
return Join-Path -Path $env:ProgramData -ChildPath 'PSCredentialStore/CredentialStore.json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,7 +48,11 @@ function Get-DefaultCredentialStorePath {
|
|||||||
if ($IsMacOS) {
|
if ($IsMacOS) {
|
||||||
return Join-Path -Path $Env:HOME -ChildPath 'CredentialStore.json'
|
return Join-Path -Path $Env:HOME -ChildPath 'CredentialStore.json'
|
||||||
}
|
}
|
||||||
elseif (($isWindows) -or ($PSVersionTable.PSVersion.Major -lt 6) -or ($PSVersionTable.PSEdition -eq 'Desktop')) {
|
elseif (
|
||||||
|
($isWindows) -or
|
||||||
|
($PSVersionTable.PSVersion.Major -lt 6) -or
|
||||||
|
($PSVersionTable.PSEdition -eq 'Desktop')
|
||||||
|
) {
|
||||||
return Join-Path -Path $env:AppData -ChildPath 'CredentialStore.json'
|
return Join-Path -Path $env:AppData -ChildPath 'CredentialStore.json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
src/Private/Get-ModuleBase.Tests.ps1
Normal file
20
src/Private/Get-ModuleBase.Tests.ps1
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
BeforeAll {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
Import-Module $ManifestFile -Force
|
||||||
|
|
||||||
|
$PrivateFunctions = (Get-ChildItem -Path "./src/Private/*.ps1" | Where-Object {
|
||||||
|
$_.BaseName -notmatch '.Tests'
|
||||||
|
}
|
||||||
|
).FullName
|
||||||
|
foreach ( $func in $PrivateFunctions) {
|
||||||
|
. $func
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Describe "Get-ModuleBase" {
|
||||||
|
Context "Basic syntax check" {
|
||||||
|
It "Test1: Should not throw" {
|
||||||
|
{ Get-ModuleBase } | Should -Not -Throw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,21 +6,13 @@ function Get-ModuleBase {
|
|||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This is just a wrapper for enabling pester tests.
|
This is just a wrapper for enabling pester tests.
|
||||||
|
|
||||||
|
|
||||||
.OUTPUTS
|
.OUTPUTS
|
||||||
Returns the base path as string
|
Returns the base path as string
|
||||||
|
#>
|
||||||
|
|
||||||
.NOTES
|
|
||||||
File Name : Get-ModuleBase.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType()]
|
[OutputType([string])]
|
||||||
param()
|
param ()
|
||||||
begin {}
|
begin {}
|
||||||
process {
|
process {
|
||||||
return $MyInvocation.MyCommand.Module.ModuleBase
|
return $MyInvocation.MyCommand.Module.ModuleBase
|
||||||
|
26
src/Private/Get-RandomAESKey.Tests.ps1
Normal file
26
src/Private/Get-RandomAESKey.Tests.ps1
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
BeforeAll {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
Import-Module $ManifestFile -Force
|
||||||
|
|
||||||
|
$PrivateFunctions = (Get-ChildItem -Path "./src/Private/*.ps1" | Where-Object {
|
||||||
|
$_.BaseName -notmatch '.Tests'
|
||||||
|
}
|
||||||
|
).FullName
|
||||||
|
foreach ( $func in $PrivateFunctions) {
|
||||||
|
. $func
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Describe "Get-RandomKey" {
|
||||||
|
Context "Basic input tests" {
|
||||||
|
It "Test1: Should not throw " {
|
||||||
|
{ Get-RandomAESKey } | Should -Not -Throw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Context "Basic syntax check" {
|
||||||
|
It "Test2: Should return a key with a length of 32 bytes" {
|
||||||
|
$Key = Get-RandomAESKey
|
||||||
|
$Key.length | Should -Be 32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,19 +14,11 @@ function Get-RandomAESKey {
|
|||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
.\Get-RandomAESKey
|
.\Get-RandomAESKey
|
||||||
|
|
||||||
.NOTES
|
|
||||||
File Name : Get-RandomAESKey.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([byte[]])]
|
[OutputType([byte[]])]
|
||||||
param()
|
param ()
|
||||||
|
|
||||||
begin {}
|
begin {}
|
||||||
|
|
||||||
|
@ -1,7 +1,20 @@
|
|||||||
|
BeforeAll {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
Import-Module $ManifestFile -Force
|
||||||
|
|
||||||
|
$PrivateFunctions = (Get-ChildItem -Path "./src/Private/*.ps1" | Where-Object {
|
||||||
|
$_.BaseName -notmatch '.Tests'
|
||||||
|
}
|
||||||
|
).FullName
|
||||||
|
foreach ( $func in $PrivateFunctions) {
|
||||||
|
. $func
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Describe "Get-TempDir" {
|
Describe "Get-TempDir" {
|
||||||
Context "Basic tests" {
|
Context "Basic tests" {
|
||||||
It "Should not throw" {
|
It "Should not throw" {
|
||||||
{Get-TempDir} | Should -Not -Throw
|
{ Get-TempDir } | Should -Not -Throw
|
||||||
}
|
}
|
||||||
It "Should return the correct os tmp path" {
|
It "Should return the correct os tmp path" {
|
||||||
$Path = Get-TempDir
|
$Path = Get-TempDir
|
||||||
@ -17,7 +30,11 @@ Describe "Get-TempDir" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($Env:APPVEYOR) {
|
if ($Env:APPVEYOR) {
|
||||||
if (($isWindows) -or ($PSVersionTable.PSVersion.Major -lt 6) -or ($PSVersionTable.PSEdition -eq 'Desktop')) {
|
if (
|
||||||
|
($isWindows) -or
|
||||||
|
($PSVersionTable.PSVersion.Major -lt 6) -or
|
||||||
|
($PSVersionTable.PSEdition -eq 'Desktop')
|
||||||
|
) {
|
||||||
$RefPath = (Resolve-Path -Path $env:TEMP).Path
|
$RefPath = (Resolve-Path -Path $env:TEMP).Path
|
||||||
$Path | Should -Be $RefPath
|
$Path | Should -Be $RefPath
|
||||||
}
|
}
|
@ -13,21 +13,14 @@ function Get-TempDir {
|
|||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Get-TempDir
|
Get-TempDir
|
||||||
|
|
||||||
.NOTES
|
|
||||||
File Name : Get-TempDir.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
[OutputType([string])]
|
[OutputType([string])]
|
||||||
param()
|
param ()
|
||||||
begin {
|
|
||||||
|
begin {}
|
||||||
|
|
||||||
}
|
|
||||||
process {
|
process {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
return (Resolve-Path -Path '/tmp/').Path
|
return (Resolve-Path -Path '/tmp/').Path
|
||||||
@ -35,10 +28,14 @@ function Get-TempDir {
|
|||||||
if ($IsMacOS) {
|
if ($IsMacOS) {
|
||||||
return (Resolve-Path -Path '/tmp/').Path
|
return (Resolve-Path -Path '/tmp/').Path
|
||||||
}
|
}
|
||||||
elseif (($isWindows) -or ($PSVersionTable.PSVersion.Major -lt 6) -or ($PSVersionTable.PSEdition -eq 'Desktop')) {
|
elseif (
|
||||||
|
($isWindows) -or
|
||||||
|
($PSVersionTable.PSVersion.Major -lt 6) -or
|
||||||
|
($PSVersionTable.PSEdition -eq 'Desktop')
|
||||||
|
) {
|
||||||
return (Resolve-Path -Path $env:TEMP).Path
|
return (Resolve-Path -Path $env:TEMP).Path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end {
|
|
||||||
}
|
end {}
|
||||||
}
|
}
|
||||||
|
108
src/Private/Import-CSPfxCertificate.ps1
Normal file
108
src/Private/Import-CSPfxCertificate.ps1
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
function Import-CSPfxCertificate {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Adds a given pfx certificate file to current user's personal certificate store.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
This function is used to import existing pfx certificate files. The Import-PFXCertificate cmdlet from the
|
||||||
|
PKI module imports the certificate into a deprecated store. Thus you can't read the private key afterwards
|
||||||
|
or using it for decrypting data.
|
||||||
|
|
||||||
|
.PARAMETER Path
|
||||||
|
Path to an existing *.pfx certificate file.
|
||||||
|
|
||||||
|
.PARAMETER StoreName
|
||||||
|
Additionally you change change the store where you want the certificate into.
|
||||||
|
|
||||||
|
.INPUTS
|
||||||
|
[None]
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
[None]
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Import-CSPfxCertificate -Path (Join-Path -Path $Env:APPDATA -ChildPath '/PSCredentialStore.pfx')
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]$Path,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateSet(
|
||||||
|
'AddressBook',
|
||||||
|
'AuthRoot',
|
||||||
|
'CertificateAuthority',
|
||||||
|
'Disallowed',
|
||||||
|
'My',
|
||||||
|
'Root',
|
||||||
|
'TrustedPeople',
|
||||||
|
'TrustedPublisher'
|
||||||
|
)]
|
||||||
|
[string]$StoreName = 'My',
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateSet(
|
||||||
|
'CurrentUser',
|
||||||
|
'LocalMachine'
|
||||||
|
)]
|
||||||
|
[string]$StoreLocation = 'CurrentUser',
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateSet(
|
||||||
|
'ReadOnly',
|
||||||
|
'ReadWrite',
|
||||||
|
'MaxAllowed',
|
||||||
|
'OpenExistingOnly',
|
||||||
|
'IncludeArchived'
|
||||||
|
)]
|
||||||
|
[string]$OpenFlags = 'ReadWrite'
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
$Store = [System.Security.Cryptography.X509Certificates.X509Store]::new($StoreName, $StoreLocation)
|
||||||
|
try {
|
||||||
|
$Store.Open($OpenFlags)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$_.Exception.Message | Write-Error -ErrorAction Stop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
try {
|
||||||
|
$cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new(
|
||||||
|
$Path,
|
||||||
|
$null,
|
||||||
|
(
|
||||||
|
[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable -bor
|
||||||
|
[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::PersistKeySet
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if (Test-CSPfxCertificate -Thumbprint $cert.Thumbprint) {
|
||||||
|
Write-Warning -Message (
|
||||||
|
'The certificate with thumbprint {0} is already present!' -f $cert.Thumbprint
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Store.Add($cert)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$_.Exception.Message | Write-Error -ErrorAction Stop
|
||||||
|
$ErrorParams = @{
|
||||||
|
ErrorAction = 'Stop'
|
||||||
|
Exception = [System.Exception]::new(
|
||||||
|
'Could not read or add the pfx certificate!'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Write-Error @ErrorParams
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end {
|
||||||
|
$Store.Close()
|
||||||
|
}
|
||||||
|
}
|
@ -1,93 +0,0 @@
|
|||||||
function Resolve-Dependency {
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Tests defined optional dependencies and returns the result as bool.
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Use this function to test for optional modules. You can use it if you provide functions which needs special
|
|
||||||
modules but you don't want to make them required.
|
|
||||||
|
|
||||||
Place a file called Dependency.json in your module root dir. The default format is:
|
|
||||||
|
|
||||||
{
|
|
||||||
"Version": 0.1,
|
|
||||||
"Mandatory": {},
|
|
||||||
"Optional": [
|
|
||||||
{
|
|
||||||
"Name": "VMware",
|
|
||||||
"Modules": [
|
|
||||||
"VMware.VimAutomation.Core"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "CiscoUCS",
|
|
||||||
"Modules": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
.PARAMETER Name
|
|
||||||
Select the dependency item name you defined in the dependency.json.
|
|
||||||
.INPUTS
|
|
||||||
[None]
|
|
||||||
|
|
||||||
.OUTPUTS
|
|
||||||
[bool]
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
If (-not (Resolve-Dependency -Name 'VMware')) {
|
|
||||||
Write-Error -Message ("Could not resolve the optional dependencies defined for {0}" -f 'VMware') -ErrorAction 'Stop'
|
|
||||||
}
|
|
||||||
|
|
||||||
.NOTES
|
|
||||||
```
|
|
||||||
File Name : ResolveDependency.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
```
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
|
||||||
[OutputType([bool])]
|
|
||||||
[CmdletBinding()]
|
|
||||||
param (
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[ValidateNotNullOrEmpty()]
|
|
||||||
[string]$Name
|
|
||||||
)
|
|
||||||
|
|
||||||
begin {
|
|
||||||
$ModuleRootDir = Get-ModuleBase
|
|
||||||
$DepFilePath = Join-Path -Path $ModuleRootDir -ChildPath "Dependency.json"
|
|
||||||
if (Test-Path -Path $DepFilePath) {
|
|
||||||
$Dependency = Get-Content -Path $DepFilePath -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-Warning ("Could not find the dependency file: {0}" -f $DepFilePath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
$SelectedDependency = $Dependency.Optional | Where-Object {$_.Name -match $Name}
|
|
||||||
# return true if there is no dependency defined
|
|
||||||
if ($null -eq $SelectedDependency) {
|
|
||||||
return $true
|
|
||||||
}
|
|
||||||
|
|
||||||
$res = @()
|
|
||||||
foreach ($Module in $SelectedDependency.Modules) {
|
|
||||||
$res += Test-Module -Name $Module
|
|
||||||
}
|
|
||||||
# return false if there was not module at all
|
|
||||||
if (($res -contains $false) -or ($res.Count -eq 0)) {
|
|
||||||
return $false
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return $true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
end {
|
|
||||||
}
|
|
||||||
}
|
|
25
src/Private/Test-CSPfxCertificate.Tests.ps1
Normal file
25
src/Private/Test-CSPfxCertificate.Tests.ps1
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
BeforeAll {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
Import-Module $ManifestFile -Force
|
||||||
|
|
||||||
|
$PrivateFunctions = (Get-ChildItem -Path "./src/Private/*.ps1" | Where-Object {
|
||||||
|
$_.BaseName -notmatch '.Tests'
|
||||||
|
}
|
||||||
|
).FullName
|
||||||
|
foreach ( $func in $PrivateFunctions) {
|
||||||
|
. $func
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Describe "Test-CSPfxCertificate" {
|
||||||
|
Context "Basic Tests" {
|
||||||
|
It "Should not Throw" {
|
||||||
|
{
|
||||||
|
Test-CSPfxCertificate -Thumbprint '12345' -StoreName My -StoreLocation CurrentUser
|
||||||
|
} | Should -Not -Throw
|
||||||
|
}
|
||||||
|
It "Should return false" {
|
||||||
|
Test-CSPfxCertificate -Thumbprint '12345' -StoreName My -StoreLocation CurrentUser | Should -Be $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
81
src/Private/Test-CSPfxCertificate.ps1
Normal file
81
src/Private/Test-CSPfxCertificate.ps1
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
function Test-CSPfxCertificate {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Tests if the given certificate exists in a store.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Use this function to ensure if a certificate is already imported into a given store.
|
||||||
|
|
||||||
|
.PARAMETER Thumbprint
|
||||||
|
Provide one or more thumbprints.
|
||||||
|
|
||||||
|
.PARAMETER StoreName
|
||||||
|
Select the store name in which you want to search the certificates.
|
||||||
|
|
||||||
|
.PARAMETER StoreLocation
|
||||||
|
Select between the both available locations CurrentUser odr LocalMachine.
|
||||||
|
|
||||||
|
.INPUTS
|
||||||
|
[None]
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
[bool]
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Test-CSPfxCertificate -Thumbprint '12345678' -StoreName 'My' -StoreLocation 'CurrentUser'
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
[OutputType([bool])]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]$Thumbprint,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateSet(
|
||||||
|
'AddressBook',
|
||||||
|
'AuthRoot',
|
||||||
|
'CertificateAuthority',
|
||||||
|
'Disallowed',
|
||||||
|
'My',
|
||||||
|
'Root',
|
||||||
|
'TrustedPeople',
|
||||||
|
'TrustedPublisher'
|
||||||
|
)]
|
||||||
|
[string]$StoreName = 'My',
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateSet(
|
||||||
|
'CurrentUser',
|
||||||
|
'LocalMachine'
|
||||||
|
)]
|
||||||
|
[string]$StoreLocation = 'CurrentUser'
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
$Store = [System.Security.Cryptography.X509Certificates.X509Store]::New($StoreName, $StoreLocation)
|
||||||
|
try {
|
||||||
|
$Store.Open('ReadOnly')
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$_.Exception.Message | Write-Error -ErrorAction Stop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
# Script analyzer issue (unused var) workaround
|
||||||
|
$null = $Thumbprint
|
||||||
|
$Cert = $Store.Certificates | Where-Object { $_.Thumbprint -eq $Thumbprint }
|
||||||
|
|
||||||
|
if ($null -eq $Cert) {
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end {
|
||||||
|
$Store.Close()
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,16 @@
|
|||||||
|
BeforeAll {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
Import-Module $ManifestFile -Force
|
||||||
|
|
||||||
|
$PrivateFunctions = (Get-ChildItem -Path "./src/Private/*.ps1" | Where-Object {
|
||||||
|
$_.BaseName -notmatch '.Tests'
|
||||||
|
}
|
||||||
|
).FullName
|
||||||
|
foreach ( $func in $PrivateFunctions) {
|
||||||
|
. $func
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Describe "Test-ModuleName" {
|
Describe "Test-ModuleName" {
|
||||||
Context "Basic input tests" {
|
Context "Basic input tests" {
|
||||||
It "Testing standard module should not throw" {
|
It "Testing standard module should not throw" {
|
||||||
@ -20,7 +33,7 @@ Describe "Test-ModuleName" {
|
|||||||
Test-Module -Name 'foobar2000' | Should -Be $false
|
Test-Module -Name 'foobar2000' | Should -Be $false
|
||||||
}
|
}
|
||||||
It "StopifFails switch should thrown an error" {
|
It "StopifFails switch should thrown an error" {
|
||||||
{Test-Module -Name 'foobar2000' -StopIfFails }| Should -Throw
|
{ Test-Module -Name 'foobar2000' -StopIfFails } | Should -Throw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -32,20 +32,11 @@ function Test-Module {
|
|||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
.\Test-Dependency -Name 'VMware.PowerCLI' -Type 'Module' -StopIfFails
|
.\Test-Dependency -Name 'VMware.PowerCLI' -Type 'Module' -StopIfFails
|
||||||
|
|
||||||
.NOTES
|
|
||||||
```
|
|
||||||
File Name : Test-Module.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
```
|
|
||||||
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[OutputType([bool])]
|
[OutputType([bool])]
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param (
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
@ -58,6 +49,7 @@ Could not find the required {0} called {1}. Please install the required {0} to r
|
|||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[switch]$StopIfFails
|
[switch]$StopIfFails
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {}
|
begin {}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
|
45
src/Store/Get-CredentialStore.Tests.ps1
Normal file
45
src/Store/Get-CredentialStore.Tests.ps1
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
BeforeAll {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
Import-Module $ManifestFile -Force
|
||||||
|
|
||||||
|
$PrivateFunctions = (Get-ChildItem -Path "./src/Private/*.ps1" | Where-Object {
|
||||||
|
$_.BaseName -notmatch '.Tests'
|
||||||
|
}
|
||||||
|
).FullName
|
||||||
|
foreach ( $func in $PrivateFunctions) {
|
||||||
|
. $func
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Describe "Get-CredentialStore" {
|
||||||
|
Context "Basic logic tests" {
|
||||||
|
It "Read CS without params" {
|
||||||
|
if (! (Test-Path -Path (Get-DefaultCredentialStorePath)) ) {
|
||||||
|
{ New-CredentialStore -Force } | Should -Not -Throw
|
||||||
|
}
|
||||||
|
{ Get-CredentialStore } | Should -Not -Throw
|
||||||
|
}
|
||||||
|
It "Read Credential Store with testing data" {
|
||||||
|
$TestCredentialStore = './resources/cs/CredentialStore.json'
|
||||||
|
$TestPfxCert = './resources/cs/PSCredentialStore.pfx'
|
||||||
|
{
|
||||||
|
Use-CSCertificate -Shared -CredentialStore $TestCredentialStore -Path $TestPfxCert
|
||||||
|
} | Should -Not -Throw
|
||||||
|
{ Get-CredentialStore -Shared -Path $TestCredentialStore } | Should -Not -Throw
|
||||||
|
}
|
||||||
|
It "Test3: Not existing path should return false" {
|
||||||
|
{
|
||||||
|
Get-CredentialStore -Shared -Path './CredentialStore.json'
|
||||||
|
} | Should -Throw "Could not find the CredentialStore."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Context "Testing invalid json data" {
|
||||||
|
It "Should throw with invalid CredentialStore" {
|
||||||
|
$BrokenCS = './resources/cs/Broken_CS.json'
|
||||||
|
Write-Verbose -Message ('BrokenCS Path: {0}' -f $BrokenCS) -Verbose
|
||||||
|
{
|
||||||
|
Get-CredentialStore -Path -Shared $BrokenCS
|
||||||
|
} | Should -Throw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,25 +23,16 @@ 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
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -50,10 +41,10 @@ function Get-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
|
||||||
}
|
}
|
||||||
@ -63,21 +54,21 @@ 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
|
||||||
}
|
}
|
||||||
|
141
src/Store/New-CredentialStore.Tests.ps1
Normal file
141
src/Store/New-CredentialStore.Tests.ps1
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
BeforeAll {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
Import-Module $ManifestFile -Force
|
||||||
|
|
||||||
|
$PrivateFunctions = (Get-ChildItem -Path "./src/Private/*.ps1" | Where-Object {
|
||||||
|
$_.BaseName -notmatch '.Tests'
|
||||||
|
}
|
||||||
|
).FullName
|
||||||
|
foreach ( $func in $PrivateFunctions) {
|
||||||
|
. $func
|
||||||
|
}
|
||||||
|
|
||||||
|
# Backup existing credential stores
|
||||||
|
$VerbosePreference = "Continue"
|
||||||
|
Write-Verbose "Backup private Credential Store..."
|
||||||
|
$CSPath = Get-DefaultCredentialStorePath
|
||||||
|
$BackupFile = "{0}.back" -f $CSPath
|
||||||
|
if (Test-Path -Path $CSPath) {
|
||||||
|
Move-Item -Path $CSPath -Destination $BackupFile
|
||||||
|
}
|
||||||
|
Write-Verbose "Backup shared CredentialStore..."
|
||||||
|
$CSShared = Get-DefaultCredentialStorePath -Shared
|
||||||
|
$BackupSharedFile = "{0}.back" -f $CSShared
|
||||||
|
if (Test-Path -Path $CSShared) {
|
||||||
|
Move-Item -Path $CSShared -Destination $BackupSharedFile
|
||||||
|
}
|
||||||
|
Write-Verbose "Remove old CredentialStore in Temp dir"
|
||||||
|
$CSTemp = Join-Path -Path (Get-TempDir) -ChildPath '/CredentialStore.json'
|
||||||
|
if (Test-Path -Path $CSTemp) {
|
||||||
|
Remove-Item -Path $CSTemp
|
||||||
|
}
|
||||||
|
$VerbosePreference = "SilentlyContinue"
|
||||||
|
}
|
||||||
|
|
||||||
|
Describe "New-CredentialStore" {
|
||||||
|
Context "Private CS tests" {
|
||||||
|
It "Create new private CredentialStore" {
|
||||||
|
$pCS = Get-DefaultCredentialStorePath
|
||||||
|
{ New-CredentialStore -Confirm:$false -Force } | Should -Not -Throw
|
||||||
|
$result = Test-Path -Path $pCS
|
||||||
|
$CS = Get-Content -Path $pCS -Raw | ConvertFrom-Json
|
||||||
|
($result -eq $true) -and ($CS.Type -eq "Private") | Should -Be $true
|
||||||
|
}
|
||||||
|
It "Try to override private Store" {
|
||||||
|
{ New-CredentialStore -Confirm:$false } | Should -Throw
|
||||||
|
}
|
||||||
|
It "Reset existing Credential Store" {
|
||||||
|
$pCS = Get-DefaultCredentialStorePath
|
||||||
|
$now = Get-Date
|
||||||
|
$CS = Get-Content -Path $pCS -Raw | ConvertFrom-Json
|
||||||
|
$CSCreation = [DateTime]$CS.Created
|
||||||
|
New-CredentialStore -Confirm:$false -Force
|
||||||
|
$now -gt $csCreation | Should -Be $true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Context "Shared CS tests" {
|
||||||
|
It "Create a new Shared Credential Store" {
|
||||||
|
$sCS = Get-DefaultCredentialStorePath -Shared
|
||||||
|
{ New-CredentialStore -Confirm:$false -Shared } | Should -Not -Throw
|
||||||
|
Test-Path -Path $sCS | Should -Be $true
|
||||||
|
}
|
||||||
|
It "Try to override existing shared CS" {
|
||||||
|
{ New-CredentialStore -Shared -Confirm:$false } | Should -Throw
|
||||||
|
}
|
||||||
|
It "Reset shared CredentialStore" {
|
||||||
|
$sCS = Get-DefaultCredentialStorePath -Shared
|
||||||
|
$now = Get-Date
|
||||||
|
$CS = Get-Content -Path $sCS -Raw | ConvertFrom-Json
|
||||||
|
$CSCreation = [DateTime]$CS.Created
|
||||||
|
New-CredentialStore -Force -Shared -Confirm:$false
|
||||||
|
$now -gt $csCreation | Should -Be $true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Context "Custom Shared CS tests" {
|
||||||
|
It "Create new custom shared" {
|
||||||
|
$cCS = Join-Path -Path (Get-TempDir) -ChildPath "CredentialStore.json"
|
||||||
|
{ New-CredentialStore -Path $cCS -Shared -Confirm:$false -SkipPFXCertCreation } | Should -Not -Throw
|
||||||
|
}
|
||||||
|
It "Try to override exiting one" {
|
||||||
|
$cCS = Join-Path -Path (Get-TempDir) -ChildPath "CredentialStore.json"
|
||||||
|
{ New-CredentialStore -Path $cCS -Shared -Confirm:$false } | Should -Throw
|
||||||
|
}
|
||||||
|
It "Reset existing custom CredentialStore" {
|
||||||
|
$cCS = Join-Path -Path (Get-TempDir) -ChildPath "CredentialStore.json"
|
||||||
|
{ New-CredentialStore -Path $cCS -Shared -Force -Confirm:$false } | Should -Not -Throw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Context "Test exception handling" {
|
||||||
|
Mock Out-File { throw "foobar exception" }
|
||||||
|
It "JSON Conversion should fail and throw" {
|
||||||
|
{
|
||||||
|
New-CredentialStore -Path (
|
||||||
|
Join-Path -Path (Get-TempDir) -ChildPath '/dummy.json'
|
||||||
|
) -Shared -Confirm:$false
|
||||||
|
} | Should -Throw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Context "Tests for Windows certificate store" {
|
||||||
|
It "Create new private store and skip certificate linking" {
|
||||||
|
{ New-CredentialStore -UseCertStore -Force } | Should -Not -Throw
|
||||||
|
$CS = Get-CredentialStore
|
||||||
|
$CS.PfxCertificate | Should -Be $null
|
||||||
|
$CS.Thumbprint | Should -Not -Be $null
|
||||||
|
$res = Test-CSCertificate -Type Private
|
||||||
|
#Write-Verbose -Message ('res: {0}' -f $res) -Verbose
|
||||||
|
$res | Should -Be $true
|
||||||
|
|
||||||
|
}
|
||||||
|
It "Create new shared store and skipt certificate linking" {
|
||||||
|
{ New-CredentialStore -Shared -UseCertStore -Force } | Should -Not -Throw
|
||||||
|
$CS = Get-CredentialStore -Shared
|
||||||
|
$CS.PfxCertificate | Should -Be $null
|
||||||
|
$CS.Thumbprint | Should -Not -Be $null
|
||||||
|
$res = Test-CSCertificate -Type Shared
|
||||||
|
#Write-Verbose -Message ('res: {0}' -f $res) -Verbose
|
||||||
|
$res | Should -Be $true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AfterAll {
|
||||||
|
# Cleanup test stores and restore existing ones.
|
||||||
|
$VerbosePreference = "Continue"
|
||||||
|
Write-Verbose "Restoring private CredentialStore"
|
||||||
|
If (Test-Path -Path $BackupFile) {
|
||||||
|
If (Test-Path -Path $CSPath) {
|
||||||
|
Remove-Item -Path $CSPath
|
||||||
|
Move-Item -Path $BackupFile -Destination $CSPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Verbose "Restoring shared CredentialStore"
|
||||||
|
If (Test-Path -Path $BackupSharedFile) {
|
||||||
|
If (Test-Path -Path $CSShared) {
|
||||||
|
Remove-Item -Path $CSShared
|
||||||
|
Move-Item -Path $BackupSharedFile -Destination $CSShared
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$VerbosePreference = "SilentlyContinue"
|
||||||
|
|
||||||
|
}
|
@ -18,6 +18,15 @@ function New-CredentialStore {
|
|||||||
.PARAMETER Force
|
.PARAMETER Force
|
||||||
Use this switch to reset an existing store. The complete content will be wiped.
|
Use this switch to reset an existing store. The complete content will be wiped.
|
||||||
|
|
||||||
|
.PARAMETER SkipPFXCertCreation
|
||||||
|
You can skip the pfx certificate creation process. This makes sense if you have a previously created cert
|
||||||
|
or want to import a cert in cross-platform environments.
|
||||||
|
|
||||||
|
.Parameter UseCertStore
|
||||||
|
Instead of using a plain pfx file beside your CredentialStore file you can import it into the user or
|
||||||
|
machine certificate store. In this case the system itself secures the cert and you don't hat to set custom
|
||||||
|
NTFS permissions so secure your shared certificate.
|
||||||
|
|
||||||
.INPUTS
|
.INPUTS
|
||||||
[None]
|
[None]
|
||||||
|
|
||||||
@ -40,50 +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')) {
|
||||||
@ -91,7 +88,8 @@ function New-CredentialStore {
|
|||||||
$ErrorParams = @{
|
$ErrorParams = @{
|
||||||
ErrorAction = 'Stop'
|
ErrorAction = 'Stop'
|
||||||
Exception = [System.IO.InvalidDataException]::new(
|
Exception = [System.IO.InvalidDataException]::new(
|
||||||
'Please provide a full path containing the credential store file name with the .json extension!'
|
'Please provide a full path containing the ' +
|
||||||
|
'credential store file name with the .json extension!'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Write-Error @ErrorParams
|
Write-Error @ErrorParams
|
||||||
@ -100,7 +98,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 conain the required file extension .json !'
|
'Your provided path does not contain the required file extension .json!'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Write-Error @ErrorParams
|
Write-Error @ErrorParams
|
||||||
@ -111,17 +109,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'
|
||||||
@ -141,7 +139,7 @@ function New-CredentialStore {
|
|||||||
OrganizationalUnitName = $PSCmdlet.ParameterSetName
|
OrganizationalUnitName = $PSCmdlet.ParameterSetName
|
||||||
CommonName = 'PSCredentialStore'
|
CommonName = 'PSCredentialStore'
|
||||||
}
|
}
|
||||||
$CRTAttribute = New-CRTAttribute @CRTParams
|
$CRTAttribute = New-CSCertAttribute @CRTParams
|
||||||
|
|
||||||
# If we are working with a ne shared store we have to create the location first.
|
# If we are working with a ne shared store we have to create the location first.
|
||||||
# Otherwise openssl fails with unknown path
|
# Otherwise openssl fails with unknown path
|
||||||
@ -171,7 +169,7 @@ function New-CredentialStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
New-PfxCertificate @PfxParams
|
New-CSCertificate @PfxParams
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
$_.Exception.Message | Write-Error
|
$_.Exception.Message | Write-Error
|
||||||
@ -202,24 +200,27 @@ function New-CredentialStore {
|
|||||||
Thumbprint = $null
|
Thumbprint = $null
|
||||||
Type = $null
|
Type = $null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||||
|
$ObjProperties.Type = 'Shared'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$ObjProperties.Type = 'Private'
|
||||||
|
}
|
||||||
|
|
||||||
if (! $SkipPFXCertCreation.IsPresent) {
|
if (! $SkipPFXCertCreation.IsPresent) {
|
||||||
$ObjProperties.Thumbprint = $FreshCert.Thumbprint
|
$ObjProperties.Thumbprint = $FreshCert.Thumbprint
|
||||||
|
|
||||||
if (!$UseCertStore.IsPresent) {
|
if ($UseCertStore.IsPresent) {
|
||||||
$ObjProperties.PfxCertificate = $PfxParams.CertName
|
Write-Verbose 'Importing new PFX certificate file...'
|
||||||
|
Import-CSCertificate -Type $ObjProperties.Type -Path $PfxParams.CertName
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Verbose 'Importing new PFX certificate file...'
|
$ObjProperties.PfxCertificate = $PfxParams.CertName
|
||||||
Import-CSCertificate -Path $PfxParams.CertName -StoreName My -StoreLocation CurrentUser
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($PSCmdlet.ParameterSetName -eq "Shared") {
|
|
||||||
$ObjProperties.Type = "Shared"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$ObjProperties.Type = "Private"
|
|
||||||
}
|
|
||||||
|
|
||||||
$CredentialStoreObj = [PSCustomObject]$ObjProperties
|
$CredentialStoreObj = [PSCustomObject]$ObjProperties
|
||||||
try {
|
try {
|
||||||
@ -242,6 +243,5 @@ function New-CredentialStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,36 @@
|
|||||||
$RepoRoot = (Get-Item -Path (Get-GitDirectory) -Force).Parent | Select-Object -ExpandProperty 'FullName'
|
BeforeAll {
|
||||||
|
$ManifestFile = (Get-Item -Path "./src/*.psd1").FullName
|
||||||
|
Import-Module $ManifestFile -Force
|
||||||
|
|
||||||
|
$PrivateFunctions = (Get-ChildItem -Path "./src/Private/*.ps1" | Where-Object {
|
||||||
|
$_.BaseName -notmatch '.Tests'
|
||||||
|
}
|
||||||
|
).FullName
|
||||||
|
foreach ( $func in $PrivateFunctions) {
|
||||||
|
. $func
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Describe "Test-CredentialStore" {
|
Describe "Test-CredentialStore" {
|
||||||
Context "Basic logic tests" {
|
Context "Basic logic tests" {
|
||||||
$TestCredentialStore = Join-Path -Path $RepoRoot -ChildPath '/resources/cs/CredentialStore.json'
|
It "Should Not Throw" {
|
||||||
It "Test1: Should Not Throw" {
|
$TestCredentialStore = './resources/cs/CredentialStore.json'
|
||||||
{ Test-CredentialStore -Shared -Path $TestCredentialStore } | Should -Not -Throw
|
{ Test-CredentialStore -Shared -Path $TestCredentialStore } | Should -Not -Throw
|
||||||
}
|
}
|
||||||
It "Test2: Read valid CredentialStore" {
|
It "Read valid CredentialStore" {
|
||||||
|
$TestCredentialStore = './resources/cs/CredentialStore.json'
|
||||||
$res = Test-CredentialStore -Shared -Path $TestCredentialStore
|
$res = Test-CredentialStore -Shared -Path $TestCredentialStore
|
||||||
$res | Should -Be $true
|
$res | Should -Be $true
|
||||||
}
|
}
|
||||||
It "Test3: Read a broken CredentialStore" {
|
It "Read a broken CredentialStore" -Skip {
|
||||||
$BrokenCS = Join-Path -Path $RepoRoot -ChildPath '{0}/resources/cs/Broken_CS.json'
|
$BrokenCS = './resources/cs/Broken_CS.json'
|
||||||
$oWarningPreference = $WarningPreference
|
$oWarningPreference = $WarningPreference
|
||||||
$WarningPreference = 'SilentlyContinue'
|
$WarningPreference = 'SilentlyContinue'
|
||||||
$res = Test-CredentialStore -Shared -Path $BrokenCS
|
$res = Test-CredentialStore -Shared -Path $BrokenCS
|
||||||
$res | Should -Be $false
|
$res | Should -Be $false
|
||||||
$WarningPreference = $oWarningPreference
|
$WarningPreference = $oWarningPreference
|
||||||
}
|
}
|
||||||
It "Test4: Not existing path should return false" {
|
It "Not existing path should return false" {
|
||||||
if ($isWindows -or ($PSVersionTable.PSVersion.Major -eq 5)) {
|
if ($isWindows -or ($PSVersionTable.PSVersion.Major -eq 5)) {
|
||||||
Test-CredentialStore -Shared -Path 'C:\foobar\CredentialStore.json' | Should -Be $false
|
Test-CredentialStore -Shared -Path 'C:\foobar\CredentialStore.json' | Should -Be $false
|
||||||
}
|
}
|
||||||
@ -26,7 +38,7 @@ Describe "Test-CredentialStore" {
|
|||||||
Test-CredentialStore -Shared -Path '/var/opt/foo.json' | Should -Be $false
|
Test-CredentialStore -Shared -Path '/var/opt/foo.json' | Should -Be $false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
It "Test5: testing private CredentialStore path" {
|
It "testing private CredentialStore path" {
|
||||||
if (Test-Path -Path (Get-DefaultCredentialStorePath)) {
|
if (Test-Path -Path (Get-DefaultCredentialStorePath)) {
|
||||||
Remove-Item -Path (Get-DefaultCredentialStorePath)
|
Remove-Item -Path (Get-DefaultCredentialStorePath)
|
||||||
}
|
}
|
@ -14,36 +14,29 @@ function Test-CredentialStore {
|
|||||||
Switch to shared mode with this param. This enforces the command to work with a shared CredentialStore which
|
Switch to shared mode with this param. This enforces the command to work with a shared CredentialStore which
|
||||||
can be decrypted across systems.
|
can be decrypted across systems.
|
||||||
|
|
||||||
.NOTES
|
.EXAMPLE
|
||||||
```
|
Test-CredentialStore -eq $true
|
||||||
File Name : Test-CredentialStore.ps1
|
|
||||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
|
||||||
Requires :
|
|
||||||
```
|
|
||||||
.LINK
|
|
||||||
https://github.com/OCram85/PSCredentialStore
|
|
||||||
#>
|
#>
|
||||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
|
||||||
param(
|
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
[OutputType([bool])]
|
||||||
|
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
|
||||||
}
|
}
|
||||||
@ -51,12 +44,12 @@ 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
src/Vendor/libressl/openssl.exe
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl/openssl.exe
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/libcrypto-41.dll
(Stored with Git LFS)
vendored
BIN
src/Vendor/libressl255/libcrypto-41.dll
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
src/Vendor/libressl255/libcrypto-41.exp
(Stored with Git LFS)
vendored
BIN
src/Vendor/libressl255/libcrypto-41.exp
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
src/Vendor/libressl255/libcrypto-41.lib
(Stored with Git LFS)
vendored
BIN
src/Vendor/libressl255/libcrypto-41.lib
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
src/Vendor/libressl255/libcrypto-41.pdb
(Stored with Git LFS)
vendored
BIN
src/Vendor/libressl255/libcrypto-41.pdb
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
src/Vendor/libressl255/libssl-43.dll
(Stored with Git LFS)
vendored
BIN
src/Vendor/libressl255/libssl-43.dll
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
src/Vendor/libressl255/libssl-43.exp
(Stored with Git LFS)
vendored
BIN
src/Vendor/libressl255/libssl-43.exp
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
src/Vendor/libressl255/libssl-43.lib
(Stored with Git LFS)
vendored
BIN
src/Vendor/libressl255/libssl-43.lib
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
src/Vendor/libressl255/libssl-43.pdb
(Stored with Git LFS)
vendored
BIN
src/Vendor/libressl255/libssl-43.pdb
(Stored with Git LFS)
vendored
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user