Compare commits
No commits in common. "master" and "1.0.548" have entirely different histories.
@ -1,32 +0,0 @@
|
||||
# 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\/.+
|
161
.drone.yml
161
.drone.yml
@ -1,151 +1,32 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: "Build Pipeline"
|
||||
name: Linux_PWSH7_Build
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
exclude:
|
||||
- droneDocs/*
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: "Pwsh FileLinter"
|
||||
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
||||
failure: ignore
|
||||
environment:
|
||||
EXCLUDE: "(.exe|.dll|.ico|.gitkeep|Vendor|.Tests.ps1)"
|
||||
- name: Environments
|
||||
image: mcr.microsoft.com/powershell:latest
|
||||
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
|
||||
- pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1' -Verbose; Invoke-ShowEnv -Verbose}"
|
||||
- pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1' -Verbose; Invoke-InstallDependencies -Verbose}"
|
||||
- name: LintTests
|
||||
image: mcr.microsoft.com/powershell:latest
|
||||
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
|
||||
- pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-InstallDependencies}"
|
||||
- pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-Linter}"
|
||||
- name: UnitTests
|
||||
image: mcr.microsoft.com/powershell:latest
|
||||
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
|
||||
- pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-InstallDependencies}"
|
||||
- pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-UnitTests}"
|
||||
- name: coverage
|
||||
image: plugins/codecov
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: GITEA_TOKEN
|
||||
base_url: https://gitea.ocram85.com
|
||||
token:
|
||||
from_secret: CodeCovToken
|
||||
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
|
||||
}"
|
||||
- coverage.xml
|
||||
|
@ -1,31 +0,0 @@
|
||||
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,25 +1,2 @@
|
||||
# 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/libressl/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.pfx filter=lfs diff=lfs merge=lfs -text
|
||||
|
@ -1,11 +0,0 @@
|
||||
----
|
||||
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.... -->
|
@ -1,48 +0,0 @@
|
||||
----
|
||||
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 -->
|
@ -1,24 +0,0 @@
|
||||
----
|
||||
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.
|
@ -1,19 +0,0 @@
|
||||
#### :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,21 +1,3 @@
|
||||
# Don't local track test builds
|
||||
bin/PSCredentialStore.zip
|
||||
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
.vscode/cSpell.json
vendored
42
.vscode/cSpell.json
vendored
@ -1,22 +1,40 @@
|
||||
// cSpell Settings
|
||||
{
|
||||
// Version of the setting file. Always 0.1
|
||||
"version": "0.2",
|
||||
"version": "0.1",
|
||||
// language - current active spelling language
|
||||
"language": "en,de,de-DE",
|
||||
"language": "en",
|
||||
// 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
|
||||
// This is useful for offensive words and common spelling errors.
|
||||
// For example "hte" should be "the"
|
||||
"flagWords": [],
|
||||
"dictionaryDefinitions": [
|
||||
{
|
||||
"name": "default",
|
||||
"path": "./dictionaries/default.txt"
|
||||
}
|
||||
],
|
||||
"dictionaries": [
|
||||
"default"
|
||||
"flagWords": [
|
||||
"hte"
|
||||
]
|
||||
}
|
0
.vscode/dictionaries/default.txt
vendored
0
.vscode/dictionaries/default.txt
vendored
13
.vscode/extensions.json
vendored
13
.vscode/extensions.json
vendored
@ -1,13 +0,0 @@
|
||||
{
|
||||
"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",
|
||||
"request": "launch",
|
||||
"name": "PowerShell Interactive Session",
|
||||
"cwd": "${workspaceRoot}"
|
||||
"cwd": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
31
.vscode/pwsh.code-snippets
vendored
31
.vscode/pwsh.code-snippets
vendored
@ -1,31 +0,0 @@
|
||||
{
|
||||
// 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,15 +1,34 @@
|
||||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
// Set basic file related options:
|
||||
"files.encoding": "utf8",
|
||||
"files.eol": "auto",
|
||||
"files.eol": "\r\n",
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"files.insertFinalNewline": true,
|
||||
// Formation and editor options
|
||||
"editor.renderWhitespace": "boundary",
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnType": true,
|
||||
"editor.rulers": [
|
||||
116
|
||||
],
|
||||
"cSpell.enabled": true,
|
||||
// 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.codeFormatting.preset": "Custom",
|
||||
// cspell spellchecker options
|
||||
"cSpell.enabledLanguageIds": [
|
||||
"c",
|
||||
"cpp",
|
||||
@ -27,26 +46,6 @@
|
||||
"text",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"yaml",
|
||||
"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
|
||||
]
|
||||
}
|
||||
|
149
.vscode/tasks.json
vendored
149
.vscode/tasks.json
vendored
@ -1,121 +1,56 @@
|
||||
// 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",
|
||||
//"windows": {
|
||||
// "options": {
|
||||
// "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",
|
||||
// Start PowerShell
|
||||
"windows": {
|
||||
"command": "${env:windir}/System32/WindowsPowerShell/v1.0/powershell.exe",
|
||||
"args": [
|
||||
"-NoProfile",
|
||||
"-Command"
|
||||
"-ExecutionPolicy",
|
||||
"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": [
|
||||
{
|
||||
"label": "DroneIO: Invoke-Linter",
|
||||
"type": "shell",
|
||||
"command": [
|
||||
"Import-Module ./tools/DroneIO.psm1;",
|
||||
"Invoke-Linterq | Format-Table -AutoSize"
|
||||
"taskName": "Test",
|
||||
"suppressTaskName": true,
|
||||
"args": [
|
||||
"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};",
|
||||
"Invoke-Command { Write-Host 'Completed Test task in task runner.' }"
|
||||
],
|
||||
"group": "test",
|
||||
"problemMatcher": [
|
||||
"$pester"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "DroneIO: Invoke-UnitTest",
|
||||
"type": "shell",
|
||||
"command": [
|
||||
"Remove-Item ./coverage.xml -ErrorAction 'SilentlyContinue';",
|
||||
"Remove-Item ./testResults.xml -ErrorAction 'SilentlyContinue';",
|
||||
"Import-Module ./tools/DroneIO.psm1;",
|
||||
"Invoke-UnitTest -CoverageFormat 'CoverageGutters' -Verbosity 'Diagnostic'"
|
||||
],
|
||||
"group": "test",
|
||||
"problemMatcher": [
|
||||
"$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"
|
||||
]
|
||||
"problemMatcher": "$pester",
|
||||
"group": {
|
||||
"kind": "test",
|
||||
"isDefault": true
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
},
|
||||
{
|
||||
"id": "DictionaryItem",
|
||||
"type": "promptString",
|
||||
"description": "Input for dictionary file default.txt"
|
||||
"taskName": "DebugBuild",
|
||||
"suppressTaskName": true,
|
||||
"args": [
|
||||
"Write-Host 'Invoking Build...';",
|
||||
"Write-Host -Object 'Test previous builds.' -ForegroundColor Blue;",
|
||||
"If (Test-Path -Path '.\\bin\\PSCredentialStore.zip') { Remove-Item -Path '.\\bin\\PSCredentialStore.zip' -Verbose};",
|
||||
"Copy-Item -Path '.\\src\\' -Destination '.\\bin\\PSCredentialStore' -Recurse -Verbose -Force;",
|
||||
"Compress-Archive -Path '.\\src\\*' -DestinationPath '.\\bin\\PSCredentialStore.zip' -Update -Verbose;"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
41
CHANGELOG.md
41
CHANGELOG.md
@ -1,41 +0,0 @@
|
||||
# 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
|
256
LICENSE
256
LICENSE
@ -1,235 +1,21 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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/>.
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Marco Blessing
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
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
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
130
README.md
130
README.md
@ -1,62 +1,23 @@
|
||||
<p align="right">
|
||||
<img src="http://forthebadge.com/images/badges/built-with-love.svg">
|
||||
<img src="http://forthebadge.com/images/badges/for-you.svg">
|
||||
</p>
|
||||
[![AppVeyor branch](https://img.shields.io/appveyor/ci/OCram85/PSCredentialStore/master.svg?style=plastic "Master Branch Build Status")](https://ci.appveyor.com/project/OCram85/pscredentialstore/branch/master)
|
||||
[![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)
|
||||
[![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)
|
||||
[![codecov](https://codecov.io/gh/OCram85/PSCredentialStore/branch/master/graph/badge.svg)](https://codecov.io/gh/OCram85/PSCredentialStore)
|
||||
[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/PSCredentialStore.svg?style=plastic "PowershellGallery Published Version")](https://www.powershellgallery.com/packages/PSCredentialStore)
|
||||
[![PowerShell Gallery](https://img.shields.io/powershellgallery/vpre/PSCredentialStore.svg?label=latest%20preview&style=plastic "PowershellGallery Latest Preview Version")](https://www.powershellgallery.com/packages/PSCredentialStore)
|
||||
[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/PSCredentialStore.svg?style=plastic "PowershellGallery Downloads")](https://www.powershellgallery.com/packages/PSCredentialStore)
|
||||
|
||||
<p align="center">
|
||||
<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>
|
||||
![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)
|
||||
![forthebadge](http://forthebadge.com/images/badges/for-you.svg)
|
||||
|
||||
<h1 align="center">
|
||||
PSCredentialStore
|
||||
</h1>
|
||||
![social-logo](/assets/social-logo.png)
|
||||
|
||||
<p align="center">
|
||||
🔐 A simple cross-platform credential manager for PSCredential objects.
|
||||
</p>
|
||||
:key: General
|
||||
=======
|
||||
|
||||
<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.
|
||||
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
|
||||
need to store credentials for non interactive usage like in scheduled tasks.
|
||||
@ -64,38 +25,38 @@ need to store credentials for non interactive usage like in scheduled tasks.
|
||||
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
|
||||
For more details read the [about_PSCredentialStore](/docs/about_PSCredentialStore.md) page on github or via CLI with
|
||||
`Get-Help about_PSCredentialStore`.
|
||||
|
||||
You can find the full [reference](docs/Readme.md) in the */docs/* path as well.
|
||||
You can find the [reference](/docs/PSCredentialStore.md) in the /docs/ path as well.
|
||||
|
||||
## :vulcan_salute: Requirements
|
||||
:vulcan_salute: Requirements
|
||||
============
|
||||
|
||||
- PowerShell >= `5.1`
|
||||
- .NET Framework >= `4.6` or .NET Core >= `1.0`
|
||||
|
||||
## :bomb: About Security
|
||||
:bomb: About Security
|
||||
============
|
||||
|
||||
> This section explains some security topics and the design decisions we made to balance the usage and security needs.
|
||||
>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.
|
||||
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.
|
||||
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.
|
||||
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
|
||||
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)*
|
||||
Here is s brief hierarchy description of the certificate location: *(First match wins)*
|
||||
|
||||
| CredentialStore Type | Certificate Location |
|
||||
| -------------------- | ---------------------- |
|
||||
@ -105,28 +66,33 @@ Here is a brief hierarchy description for the certificate lookup order: *(First
|
||||
| Shared (Linux) | `LocalMachine`\\`My` |
|
||||
| | `LocalMachine`\\`Root` |
|
||||
|
||||
## :hammer_and_wrench: Installation
|
||||
|
||||
### :artificial_satellite: PowerShellGallery.com (Recommended Way)
|
||||
|
||||
:hammer_and_wrench: Installation
|
||||
============
|
||||
|
||||
:artificial_satellite: PowerShellGallery.com (Recommended Way)
|
||||
---------------------------------------
|
||||
|
||||
* Make sure you use PowerShell 5.1 or higher with `$PSVersionTable`.
|
||||
* Use the builtin PackageManagement + PowerShellGet module and install PSCredentialStore with: `Import-Module PowerShellGet; Install-Module 'PSCredentialStore' -Repository 'PSGallery'`
|
||||
* Use the builtin PackageManagement and install with: `Import-Module PowerShellGet; Install-Module 'PSCredentialStore' -Repository 'PSGallery'`
|
||||
* 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`
|
||||
|
||||
### :building_construction: Manual Way
|
||||
:building_construction: Manual Way
|
||||
----------
|
||||
|
||||
* Take a look at the [Latest Release](https://gitea.ocram85.com/OCram85/PSCredentialStore/releases/latest) page.
|
||||
* Take a look at the [Latest Release](https://github.com/OCram85/PSCredentialStore/releases/latest) page.
|
||||
* Download the `PSCredentialStore.zip`.
|
||||
* 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.
|
||||
* Start with `Import-Module PSCredentialStore`
|
||||
|
||||
### :sparkles: 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.
|
||||
**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.
|
||||
|
||||
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
|
||||
@ -142,12 +108,11 @@ New-CredentialStore -UseCertStore
|
||||
# Shared credential store
|
||||
New-CredentialStore -Shared
|
||||
|
||||
# Shared credential store in custom location
|
||||
#Shared credential store in custom location
|
||||
New-CredentialStore -Shared -Path 'C:\CredentialStore.json'
|
||||
```
|
||||
|
||||
**2.** Now you can manage your credential store items:
|
||||
|
||||
```powershell
|
||||
# This will prompt for credentials and stores it in a private store
|
||||
New-CredentialStoreItem -RemoteHost 'dc01.myside.local' -Identifier 'AD'
|
||||
@ -158,7 +123,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.
|
||||
If you have already installed the underlying framework / modules, you can connect to these endpoint types:
|
||||
If you have already installed the underlying framework / modules, you can connect these endpoints:
|
||||
|
||||
* **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)
|
||||
@ -190,7 +155,8 @@ Connect-To -RemoteHost "exchange1.myside.local" -Type ExchangeHTTPS
|
||||
Connect-To -RemoteHost "ubuntu.myside.local" -Type SCP
|
||||
```
|
||||
|
||||
### :pushpin: Credits
|
||||
:pushpin: Credits
|
||||
-------
|
||||
|
||||
A huge thanks to all the people who helped with their projects and indirect contributions which made this possible!
|
||||
|
||||
|
42
_.travis.yml
Normal file
42
_.travis.yml
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
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
|
74
appveyor.yml
Normal file
74
appveyor.yml
Normal file
@ -0,0 +1,74 @@
|
||||
# pre release version:
|
||||
version: 1.0.{build}
|
||||
|
||||
#cache:
|
||||
|
||||
#branches:
|
||||
# only:
|
||||
# - master
|
||||
# - dev
|
||||
# - debug
|
||||
|
||||
skip_tags: true
|
||||
|
||||
image: Visual Studio 2019
|
||||
|
||||
# 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
|
||||
CodeCovToken:
|
||||
secure: LJOvamWIlVORDE7120KcmWVkHxOFYBSN99linyICXXmXLtYm81K/31YeMGiPlgTm
|
||||
|
||||
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: false
|
||||
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'))
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Connect-To
|
||||
|
||||
## SYNOPSIS
|
||||
@ -29,42 +22,37 @@ Establish a connection to the selected host using a stored CredentialStoreItem.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
Connect-To -RemoteHost "ucs.myside.local" -Type CiscoUcs
|
||||
```
|
||||
|
||||
### EXAMPLE 2
|
||||
```
|
||||
Connect-To -RemoteHost "ucscentral.myside.local" -Type 'CiscoUcsCentral'
|
||||
```
|
||||
|
||||
### EXAMPLE 3
|
||||
### BEISPIEL 2
|
||||
```
|
||||
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
|
||||
```
|
||||
|
||||
### EXAMPLE 4
|
||||
### BEISPIEL 3
|
||||
```
|
||||
Connect-To -RemoteHost "fas.myside.local" -Type NetAppFAS
|
||||
```
|
||||
|
||||
### EXAMPLE 5
|
||||
### BEISPIEL 4
|
||||
```
|
||||
Connect-To -RemoteHost "esx01.myside.local" -Type VMware
|
||||
```
|
||||
|
||||
### EXAMPLE 6
|
||||
### BEISPIEL 5
|
||||
```
|
||||
Connect-To -RemoteHost "vCenter.myside.local" -Type CisServer
|
||||
```
|
||||
|
||||
### EXAMPLE 7
|
||||
### BEISPIEL 6
|
||||
```
|
||||
Connect-To -RemoteHost "exchange01.myside.local" -Type ExchangeHTTP
|
||||
```
|
||||
|
||||
### EXAMPLE 8
|
||||
### BEISPIEL 7
|
||||
```
|
||||
Connect-To -RemoteHost "exchange01.myside.local" -Type ExchangeHTTPS
|
||||
```
|
||||
@ -172,16 +160,7 @@ Accept wildcard characters: False
|
||||
### -Type
|
||||
Specify the host type of the target.
|
||||
Currently implemented targets are: Possible connection values are:
|
||||
|
||||
- CiscoUcs
|
||||
- CiscoUcsCentral
|
||||
- CisServer
|
||||
- ExchangeHTTP
|
||||
- ExchangeHTTPS
|
||||
- FTP
|
||||
- NetAppFAS
|
||||
- SCP
|
||||
- VMware
|
||||
CiscoUcs, FTP, NetAppFAS, VMware, CisServer, ExchangeHTTP, ExchangeHTTPS, SCP.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
@ -205,5 +184,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [None]
|
||||
## NOTES
|
||||
- File Name : Connect-To.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Disconnect-From
|
||||
|
||||
## SYNOPSIS
|
||||
@ -21,42 +14,42 @@ Terminates a session established with Connect-To using a CredentialStoreItem.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
Disconnect-From -RemoteHost "ucs.myside.local" -Type CiscoUcs
|
||||
```
|
||||
|
||||
### EXAMPLE 2
|
||||
### BEISPIEL 2
|
||||
```
|
||||
Disconnect-From -RemoteHost "ftp.myside.local" -Type FTP
|
||||
```
|
||||
|
||||
### EXAMPLE 3
|
||||
### BEISPIEL 3
|
||||
```
|
||||
Disconnect-From -RemoteHost "fas.myside.local" -Type NetAppFAS
|
||||
```
|
||||
|
||||
### EXAMPLE 4
|
||||
### BEISPIEL 4
|
||||
```
|
||||
Disconnect-From -RemoteHost "esx01.myside.local" -Type VMware
|
||||
```
|
||||
|
||||
### EXAMPLE 5
|
||||
### BEISPIEL 5
|
||||
```
|
||||
Disconnect-From -RemoteHost "esx01.myside.local" -Type VMware -Force:$True
|
||||
```
|
||||
|
||||
### EXAMPLE 6
|
||||
### BEISPIEL 6
|
||||
```
|
||||
Disconnect-From -RemoteHost "vcenter.myside.local" -Type CisServer
|
||||
```
|
||||
|
||||
### EXAMPLE 7
|
||||
### BEISPIEL 7
|
||||
```
|
||||
Disconnect-From -RemoteHost "exchange01.myside.local" -Type ExchangeHTTP
|
||||
```
|
||||
|
||||
### EXAMPLE 8
|
||||
### BEISPIEL 8
|
||||
```
|
||||
Disconnect-From -RemoteHost "exchange01.myside.local" -Type ExchangeHTTPS
|
||||
```
|
||||
@ -95,17 +88,8 @@ Accept wildcard characters: False
|
||||
|
||||
### -Type
|
||||
Specify the host type of the target.
|
||||
Currently implemented targets are:
|
||||
|
||||
- CiscoUcs
|
||||
- CiscoUcsCentral
|
||||
- FTP
|
||||
- NetAppFAS
|
||||
- VMware
|
||||
- CisServer
|
||||
- ExchangeHTTP
|
||||
- ExchangeHTTPS
|
||||
- SCP
|
||||
Currently implemented targets are: CiscoUcs, FTP, NetAppFAS, VMware,
|
||||
CisServer, ExchangeHTTP, ExchangeHTTPS, SCP.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
@ -129,5 +113,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [None]
|
||||
## NOTES
|
||||
- File Name : Disconnect-From.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Get-CSCertificate
|
||||
|
||||
## SYNOPSIS
|
||||
@ -21,7 +14,7 @@ Use this function to get the available pfx certificate respecting the config hie
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
Get-CSCertificate -Type 'Shared' -Thumbprint '12334456'
|
||||
```
|
||||
@ -68,5 +61,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [System.Security.Cryptography.X509Certificates.X509Certificate2]
|
||||
## NOTES
|
||||
- File Name : Get-CSCertificate.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Get-CredentialStore
|
||||
|
||||
## SYNOPSIS
|
||||
@ -31,7 +24,7 @@ Get-CredentialStoreItem.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
$CSContent = Get-CredentialStore -Path "C:\TMP\mystore.json"
|
||||
```
|
||||
@ -80,5 +73,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [PSObject] Returns the credential store content as PSObject.
|
||||
## NOTES
|
||||
- File Name : Get-CredentialStore.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Get-CredentialStoreItem
|
||||
|
||||
## SYNOPSIS
|
||||
@ -28,7 +21,7 @@ Return the credential as PSCredential object.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
$myCreds = Get-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||
```
|
||||
@ -110,5 +103,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [System.Management.Automation.PSCredential]
|
||||
## NOTES
|
||||
- File Name : Get-CredentialStoreItem.ps1
|
||||
- Author : Messing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Import-CSCertificate
|
||||
|
||||
## SYNOPSIS
|
||||
@ -22,7 +15,7 @@ private and shared credential stores.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
Import-CSCertificate -Type 'Private' -Path (Join-Path -Path $Env:APPDATA -ChildItem 'PfxCertificate.pfx')
|
||||
```
|
||||
@ -69,5 +62,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [None]
|
||||
## NOTES
|
||||
- File Name : Import-CSCertificate.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# New-CSCertAttribute
|
||||
|
||||
## SYNOPSIS
|
||||
@ -22,17 +15,9 @@ Defines the certificate related properties for an upcoming New-PfxCertificate ex
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
$AttribParams = @{
|
||||
Country = 'DE'
|
||||
State = 'BW'
|
||||
City = 'Karlsruhe'
|
||||
Organization ='AwesomeIT'
|
||||
OrganizationalUnitName ='PSCredentialStore'
|
||||
CommonName ='MyPrivateCert'
|
||||
}
|
||||
New-CSCertAttribute @AttribParams
|
||||
New-CSCertAttribute -Country 'DE' -State 'BW' -City 'Karlsruhe' -Organization 'AwesomeIT' -OrganizationalUnitName '' -CommonName 'MyPrivateCert'
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
@ -152,5 +137,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [PSCredentialStore.Certificate.CSRDetails]
|
||||
## NOTES
|
||||
- File Name : New-CSCertAttribute.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# New-CSCertificate
|
||||
|
||||
## SYNOPSIS
|
||||
@ -22,7 +15,7 @@ Use this function to create a custom self signed certificate used by the PSCrede
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
New-CSCertificate -CRTAttribute $CRTAttribute -KeyName './myprivate.key' -CertName './mycert.pfx'
|
||||
```
|
||||
@ -117,5 +110,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [None]
|
||||
## NOTES
|
||||
- File Name : New-CSCertificate.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# New-CredentialStore
|
||||
|
||||
## SYNOPSIS
|
||||
@ -30,30 +23,34 @@ save new credentials with New-CredentialStoreItem.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
New-CredentialStore
|
||||
# Creates a new private CredentialStore
|
||||
```
|
||||
|
||||
### EXAMPLE 2
|
||||
# Creates a new private CredentialStore
|
||||
|
||||
### BEISPIEL 2
|
||||
```
|
||||
New-CredentialStore -Force
|
||||
# Resets an existing private CredentialStore
|
||||
```
|
||||
|
||||
### EXAMPLE 3
|
||||
# Resets an existing private CredentialStore
|
||||
|
||||
### BEISPIEL 3
|
||||
```
|
||||
New-CredentialStore -Shared
|
||||
# Creates a new shared CredentialStore
|
||||
```
|
||||
|
||||
### EXAMPLE 4
|
||||
# Creates a new shared CredentialStore
|
||||
|
||||
### BEISPIEL 4
|
||||
```
|
||||
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.
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -Force
|
||||
@ -124,8 +121,8 @@ 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.
|
||||
This makes sense if you have a previously created cert or want to
|
||||
import a cert in cross-platform environments.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
@ -140,10 +137,10 @@ 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.
|
||||
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
|
||||
@ -199,5 +196,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
### ['PSCredentialStore.Store'] Returns the recently created CredentialStore object if the -PassThru parameter
|
||||
### was given.
|
||||
## NOTES
|
||||
- File Name : New-CredentialStore.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# New-CredentialStoreItem
|
||||
|
||||
## SYNOPSIS
|
||||
@ -33,7 +26,7 @@ a VIConnection, NetApp FAS or UCS Fabric Interconnect.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
New-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||
```
|
||||
@ -130,5 +123,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [None]
|
||||
## NOTES
|
||||
- File Name : New-CredentialStoreItem.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,14 +1,6 @@
|
||||
---
|
||||
Module Name: PSCredentialStore
|
||||
Module Guid: 6800e192-9df8-4e30-b253-eb2c799bbe84
|
||||
Download Help Link: {{ Update Download Link }}
|
||||
Help Version: {{ Please enter version of help manually (X.X.X.X) format }}
|
||||
Locale: en-US
|
||||
---
|
||||
|
||||
# PSCredentialStore Module
|
||||
## Description
|
||||
See global Readme file for usage instructions.
|
||||
[about_PSCredentialStore](about_PSCredentialStore.md)
|
||||
|
||||
## PSCredentialStore Cmdlets
|
||||
### [Connect-To](Connect-To.md)
|
||||
@ -29,8 +21,8 @@ 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
|
||||
### [Import-CSCertificate](Import-CSCertificate.md)
|
||||
Imports a linked certificate to the valid store location.
|
||||
|
||||
### [New-CredentialStoreItem](New-CredentialStoreItem.md)
|
||||
Adds a credential store item containing host, user and password to the given store.
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Remove-CredentialStoreItem
|
||||
|
||||
## SYNOPSIS
|
||||
@ -28,22 +21,22 @@ Use this CMDLet to completely remove an credential store item.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
Remove-CredentialStoreItem -RemoteHost "esx01.myside.local"
|
||||
```
|
||||
|
||||
### EXAMPLE 2
|
||||
### BEISPIEL 2
|
||||
```
|
||||
Remove-CredentialStoreItem -Shared -RemoteHost "esx01.myside.local"
|
||||
```
|
||||
|
||||
### EXAMPLE 3
|
||||
### BEISPIEL 3
|
||||
```
|
||||
Remove-CredentialStoreItem -Shared -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||
```
|
||||
|
||||
### EXAMPLE 4
|
||||
### BEISPIEL 4
|
||||
```
|
||||
Remove-CredentialStoreItem -RemoteHost "esx01.myside.local" -Identifier svc
|
||||
```
|
||||
@ -124,5 +117,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [None]
|
||||
## NOTES
|
||||
- File Name : Remove-CredentialStoreItem.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Set-CredentialStoreItem
|
||||
|
||||
## SYNOPSIS
|
||||
@ -29,12 +22,12 @@ Use this function to update your already stored RemoteHost items.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
Set-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||
```
|
||||
|
||||
### EXAMPLE 2
|
||||
### BEISPIEL 2
|
||||
```
|
||||
Set-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local" -Identifier svc
|
||||
```
|
||||
@ -130,5 +123,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [None]
|
||||
## NOTES
|
||||
- File Name : Set-CredentialStoreItem.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Test-CSCertificate
|
||||
|
||||
## SYNOPSIS
|
||||
@ -21,7 +14,7 @@ Test-CSCertificate should be an easy high level test for the linked certificate.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
Test-CSCertificate -Type 'Shared'
|
||||
```
|
||||
@ -53,5 +46,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [bool]
|
||||
## NOTES
|
||||
- File Name : Test-CSCertificate.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Test-CSConnection
|
||||
|
||||
## SYNOPSIS
|
||||
@ -21,7 +14,7 @@ Use this script to check a connection which was established with the \`Connect-T
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
Test-CMConnection -RemoteHost "vcr01.internal.net" -Type VMware
|
||||
```
|
||||
@ -70,5 +63,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [bool]
|
||||
## NOTES
|
||||
- File Name : Test-CSConnection.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Test-CredentialStore
|
||||
|
||||
## SYNOPSIS
|
||||
@ -29,7 +22,7 @@ the file exists.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
Test-CredentialStore -eq $true
|
||||
```
|
||||
@ -75,7 +68,12 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
### System.Boolean
|
||||
## NOTES
|
||||
- File Name : Test-CredentialStore.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Test-CredentialStoreItem
|
||||
|
||||
## SYNOPSIS
|
||||
@ -28,22 +21,18 @@ Use this cmdlet for basic checks with a single item.
|
||||
Check the item first with this function before
|
||||
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
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
if (Test-CredentialStoreItem -RemoteHost "Default") {
|
||||
Get-CredentialStoreItem -RemoteHost "Default"
|
||||
If (Test-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)
|
||||
}
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
@ -123,5 +112,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [None]
|
||||
## NOTES
|
||||
- File Name : Test-CredentialStoreItem.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
---
|
||||
external help file: ModuleRoot-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Use-CSCertificate
|
||||
|
||||
## SYNOPSIS
|
||||
@ -27,7 +20,7 @@ Linking a certificate is needed if you plan to use the same CredentialStore in c
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
### BEISPIEL 1
|
||||
```
|
||||
Use-CSCertificate -Path 'C:\cert.pfx'
|
||||
```
|
||||
@ -104,5 +97,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
### [None]
|
||||
## NOTES
|
||||
File Name : Use-CSCertificate.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
[https://github.com/OCram85/PSCredentialStore](https://github.com/OCram85/PSCredentialStore)
|
||||
|
||||
|
@ -18,7 +18,7 @@ need to store credentials for non interactive usage like in scheduled tasks.
|
||||
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
|
||||
For more details read the [about_PSCredentialStore](/docs/about_PSCredentialStore.md) page on github or via CLI with
|
||||
`Get-Help about_PSCredentialStore`.
|
||||
|
||||
## Requirements
|
||||
|
38
resources/Dependency.json
Normal file
38
resources/Dependency.json
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,139 +0,0 @@
|
||||
@{
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -20,11 +20,18 @@ function Get-CSCertificate {
|
||||
|
||||
.EXAMPLE
|
||||
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()]
|
||||
[OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2])]
|
||||
param (
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[ValidateSet('Private', 'Shared')]
|
||||
@ -35,8 +42,8 @@ function Get-CSCertificate {
|
||||
[string]$Thumbprint
|
||||
)
|
||||
|
||||
begin {}
|
||||
|
||||
begin {
|
||||
}
|
||||
process {
|
||||
if ($Type -eq 'Private') {
|
||||
Get-CSPfXCertificate -Thumbprint $Thumbprint -StoreName 'My' -StoreLocation 'CurrentUser'
|
||||
@ -62,5 +69,6 @@ function Get-CSCertificate {
|
||||
}
|
||||
}
|
||||
}
|
||||
end {}
|
||||
end {
|
||||
}
|
||||
}
|
||||
|
@ -21,10 +21,18 @@ function Import-CSCertificate {
|
||||
|
||||
.EXAMPLE
|
||||
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()]
|
||||
param (
|
||||
[OutputType()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[ValidateSet('Private', 'Shared')]
|
||||
|
@ -1,20 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@ -34,25 +34,19 @@ function New-CSCertAttribute {
|
||||
[PSCredentialStore.Certificate.CSRDetails]
|
||||
|
||||
.EXAMPLE
|
||||
$AttribParams = @{
|
||||
Country = 'DE'
|
||||
State = 'BW'
|
||||
City = 'Karlsruhe'
|
||||
Organization ='AwesomeIT'
|
||||
OrganizationalUnitName ='PSCredentialStore'
|
||||
CommonName ='MyPrivateCert'
|
||||
}
|
||||
New-CSCertAttribute @AttribParams
|
||||
#>
|
||||
New-CSCertAttribute -Country 'DE' -State 'BW' -City 'Karlsruhe' -Organization 'AwesomeIT' -OrganizationalUnitName '' -CommonName 'MyPrivateCert'
|
||||
|
||||
.NOTES
|
||||
- File Name : New-CSCertAttribute.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||
'PSUseShouldProcessForStateChangingFunctions',
|
||||
'',
|
||||
Justification = 'Returns a new object and does not change data'
|
||||
)]
|
||||
[OutputType('PSCredentialStore.Certificate.Attribute')]
|
||||
param (
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateLength(2, 2)]
|
||||
[ValidateNotNull()]
|
||||
@ -82,8 +76,9 @@ function New-CSCertAttribute {
|
||||
[ValidateNotNull()]
|
||||
[int]$Days = 365
|
||||
)
|
||||
begin {}
|
||||
begin {
|
||||
|
||||
}
|
||||
process {
|
||||
return [PSCustomObject]@{
|
||||
PSTypeName = 'PSCredentialStore.Certificate.Attribute'
|
||||
@ -99,5 +94,6 @@ function New-CSCertAttribute {
|
||||
Days = $Days
|
||||
}
|
||||
}
|
||||
end {}
|
||||
end {
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@ -23,16 +23,18 @@ function New-CSCertificate {
|
||||
|
||||
.EXAMPLE
|
||||
New-CSCertificate -CRTAttribute $CRTAttribute -KeyName './myprivate.key' -CertName './mycert.pfx'
|
||||
#>
|
||||
|
||||
.NOTES
|
||||
- File Name : New-CSCertificate.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
[CmdletBinding(SupportsShouldProcess = $true)]
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||
'PSAvoidUsingInvokeExpression',
|
||||
'',
|
||||
Justification = 'needed for openssl wrapping'
|
||||
)]
|
||||
[OutputType()]
|
||||
param (
|
||||
param(
|
||||
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[PSTypeName('PSCredentialStore.Certificate.Attribute')]$CRTAttribute,
|
||||
@ -62,16 +64,12 @@ function New-CSCertificate {
|
||||
Write-Error @ErrorParams
|
||||
}
|
||||
}
|
||||
elseif (
|
||||
($PSVersionTable.PSEdition -eq 'Desktop' -and $PSVersionTable.PSVersion.Major -lt 6) -or
|
||||
($IsWindows -eq $true)
|
||||
) {
|
||||
$openssl = Join-Path -Path $ModuleBase -ChildPath '/Vendor/libressl/openssl.exe'
|
||||
elseif (($PSVersionTable.PSEdition -eq 'Desktop' -and $PSVersionTable.PSVersion.Major -lt 6) -or ($IsWindows -eq $true)) {
|
||||
$openssl = Join-Path -Path $ModuleBase -ChildPath '/Vendor/libressl255/openssl.exe'
|
||||
}
|
||||
|
||||
$Env:OPENSSL_CONF = Join-Path $ModuleBase -ChildPath '/openssl.conf'
|
||||
}
|
||||
|
||||
process {
|
||||
$SubjPattern = "/C={0}/ST={1}/L={2}/O={3}/OU={4}/CN={5}"
|
||||
$SubjValues = @(
|
||||
@ -85,9 +83,7 @@ function New-CSCertificate {
|
||||
$Subj = $SubjPattern -f $SubjValues
|
||||
|
||||
$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 = @(
|
||||
$openssl,
|
||||
$CRTAttribute.Days
|
||||
|
@ -17,11 +17,18 @@ function Test-CSCertificate {
|
||||
|
||||
.EXAMPLE
|
||||
Test-CSCertificate -Type 'Shared'
|
||||
#>
|
||||
|
||||
.NOTES
|
||||
- File Name : Test-CSCertificate.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
[OutputType([bool])]
|
||||
param (
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[ValidateSet('Private', 'Shared')]
|
||||
@ -35,10 +42,7 @@ function Test-CSCertificate {
|
||||
$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!'
|
||||
)
|
||||
Write-Warning 'There is a Pfx certificate file linked in the store. Certificates saved in the Cert store will be ignored!'
|
||||
}
|
||||
|
||||
}
|
||||
@ -50,28 +54,13 @@ function Test-CSCertificate {
|
||||
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
|
||||
$cert = Get-CSPfxCertificate -Thumbprint $CS.Thumbprint -StoreName 'Root' -StoreLocation 'LocalMachine'
|
||||
}
|
||||
}
|
||||
elseif ( (! $isLinux) -or ($isWindows) ) {
|
||||
$PFXParams = @{
|
||||
Thumbprint = $CS.Thumbprint
|
||||
StoreName = 'My'
|
||||
StoreLocation = 'LocalMachine'
|
||||
}
|
||||
$cert = Get-CSPfxCertificate @PFXParams
|
||||
$cert = Get-CSPfxCertificate -Thumbprint $CS.Thumbprint -StoreName 'My' -StoreLocation 'LocalMachine'
|
||||
if ($null -eq $cert) {
|
||||
$PFXParams = @{
|
||||
Thumbprint = $CS.Thumbprint
|
||||
StoreName = 'Root'
|
||||
StoreLocation = 'LocalMachine'
|
||||
}
|
||||
$cert = Get-CSPfxCertificate @PFXParams
|
||||
$cert = Get-CSPfxCertificate -Thumbprint $CS.Thumbprint -StoreName 'Root' -StoreLocation 'LocalMachine'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,28 +26,36 @@ function Use-CSCertificate {
|
||||
|
||||
.EXAMPLE
|
||||
Use-CSCertificate -Path 'C:\cert.pfx'
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||
.NOTES
|
||||
File Name : Use-CSCertificate.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
||||
[OutputType()]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "")]
|
||||
param (
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
param(
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Path,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$CredentialStore,
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[switch]$Shared,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[switch]$UseCertStore
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[Switch]$UseCertStore
|
||||
)
|
||||
begin {}
|
||||
begin { }
|
||||
|
||||
process {
|
||||
try {
|
||||
@ -66,11 +74,11 @@ function Use-CSCertificate {
|
||||
}
|
||||
|
||||
try {
|
||||
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
||||
$StorePath = Get-DefaultCredentialStorePath
|
||||
$CS = Get-CredentialStore
|
||||
}
|
||||
elseif ($PSCmdlet.ParameterSetName -eq 'Shared' ) {
|
||||
elseif ($PSCmdlet.ParameterSetName -eq "Shared" ) {
|
||||
if (!($PSBoundParameters.ContainsKey('CredentialStore'))) {
|
||||
$StorePath = Get-DefaultCredentialStorePath -Shared
|
||||
$CS = Get-CredentialStore -Shared
|
||||
@ -109,5 +117,5 @@ Make sure you used the same AES keys for encrypting!
|
||||
$CS | ConvertTo-Json -Depth 5 | Out-File -FilePath $StorePath -Force -Encoding utf8
|
||||
}
|
||||
|
||||
end {}
|
||||
end { }
|
||||
}
|
||||
|
@ -15,16 +15,7 @@ function Connect-To {
|
||||
|
||||
.PARAMETER Type
|
||||
Specify the host type of the target. Currently implemented targets are: Possible connection values are:
|
||||
|
||||
- CiscoUcs
|
||||
- CiscoUcsCentral
|
||||
- CisServer
|
||||
- ExchangeHTTP
|
||||
- ExchangeHTTPS
|
||||
- FTP
|
||||
- NetAppFAS
|
||||
- SCP
|
||||
- VMware
|
||||
CiscoUcs, FTP, NetAppFAS, VMware, CisServer, ExchangeHTTP, ExchangeHTTPS, SCP.
|
||||
|
||||
.PARAMETER Credentials
|
||||
Use this parameter to bypass the stored credentials. Without this parameter Connect-To tries to read the
|
||||
@ -50,9 +41,6 @@ function Connect-To {
|
||||
.EXAMPLE
|
||||
Connect-To -RemoteHost "ucs.myside.local" -Type CiscoUcs
|
||||
|
||||
.EXAMPLE
|
||||
Connect-To -RemoteHost "ucscentral.myside.local" -Type 'CiscoUcsCentral'
|
||||
|
||||
.EXAMPLE
|
||||
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
|
||||
|
||||
@ -70,28 +58,30 @@ function Connect-To {
|
||||
|
||||
.EXAMPLE
|
||||
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')]
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||
'PSAvoidGlobalVars',
|
||||
'',
|
||||
Justification = 'Wrapping existing var from WinSCP module.'
|
||||
)]
|
||||
param (
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
||||
param(
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
||||
[string]$RemoteHost,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
||||
[string]$Identifier,
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
||||
[ValidateSet(
|
||||
'CiscoUcs',
|
||||
'CiscoUcsCentral',
|
||||
'FTP',
|
||||
'NetAppFAS',
|
||||
'VMware',
|
||||
@ -102,34 +92,38 @@ function Connect-To {
|
||||
)]
|
||||
[string]$Type,
|
||||
|
||||
[Parameter(Mandatory = $False, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $False, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $False, ParameterSetName = "Shared")]
|
||||
[Parameter(Mandatory = $False, ParameterSetName = "Private")]
|
||||
[PSCredential]$Credentials,
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetNAme = 'Shared')]
|
||||
[Parameter(Mandatory = $true, ParameterSetNAme = "Shared")]
|
||||
[switch]$Shared,
|
||||
|
||||
[Parameter(Mandatory = $False, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $False, ParameterSetName = "Shared")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Path,
|
||||
|
||||
[Parameter(Mandatory = $False, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $False, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $False, ParameterSetName = "Private")]
|
||||
[Parameter(Mandatory = $False, ParameterSetName = "Shared")]
|
||||
[switch]$PassThru
|
||||
)
|
||||
|
||||
begin {
|
||||
# Set the CredentialStore for private, shared or custom mode.
|
||||
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
||||
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
||||
$Path = Get-DefaultCredentialStorePath
|
||||
}
|
||||
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||
elseif ($PSCmdlet.ParameterSetName -eq "Shared") {
|
||||
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
||||
$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) {
|
||||
"VMware" {
|
||||
# Disable the yellow certificate warning, since we haven't replaced the SSL certs for vCenter/ESXi
|
||||
@ -160,11 +154,8 @@ function Connect-To {
|
||||
|
||||
catch {
|
||||
$MessageParams = @{
|
||||
Message = (
|
||||
"Unable to look up credential store item for RemoteHost " +
|
||||
("{0}/Identifier {1}!" -f $RemoteHost, $Identifier)
|
||||
)
|
||||
ErrorAction = 'Stop'
|
||||
Message = "Unable to look up credential store item for RemoteHost {0}/Identifier {1}!" -f $RemoteHost, $Identifier
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -173,10 +164,10 @@ function Connect-To {
|
||||
$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 = @{
|
||||
Message = "Please provide valid credentials for RemoteHost {0}!" -f $RemoteHost
|
||||
ErrorAction = 'Stop'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -184,28 +175,14 @@ function Connect-To {
|
||||
switch ($Type) {
|
||||
"CiscoUcs" {
|
||||
try {
|
||||
$handle = Connect-Ucs -Name $RemoteHost -Credential $creds -ErrorAction 'Stop' -NotDefault
|
||||
$ExecutionContext.SessionState.PSVariable.Set('DefaultUcs', $handle)
|
||||
$handle = Connect-Ucs -Name $RemoteHost -Credential $creds -ErrorAction Stop
|
||||
$ExecutionContext.SessionState.PSVariable.Set("DefaultUcs", $handle)
|
||||
}
|
||||
|
||||
catch {
|
||||
$MessageParams = @{
|
||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||
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'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -229,11 +206,8 @@ function Connect-To {
|
||||
if (!($WinSCPSession.Opened)) {
|
||||
# Check the connection state and find out if the session is still open.
|
||||
$MessageParams = @{
|
||||
Message = (
|
||||
("Connection to {0} using Type {1} " -f $RemoteHost, $Type) +
|
||||
"was established. But now it seems to be lost!"
|
||||
)
|
||||
ErrorAction = 'Stop'
|
||||
Message = "Connection to {0} using Type {1} was established. But now it seems to be lost!" -f $RemoteHost, $Type
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -247,7 +221,7 @@ function Connect-To {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = 'Stop'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -261,7 +235,7 @@ function Connect-To {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = 'Stop'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -281,7 +255,7 @@ function Connect-To {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = 'Stop'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -295,14 +269,12 @@ function Connect-To {
|
||||
ErrorAction = 'Stop'
|
||||
}
|
||||
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
|
||||
# ScriptAnalyzer issue (unused var) workaround.
|
||||
$null = $Global:PSExchangeRemote
|
||||
}
|
||||
catch {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = 'Stop'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -321,7 +293,7 @@ function Connect-To {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = 'Stop'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -336,15 +308,13 @@ function Connect-To {
|
||||
try {
|
||||
$SessionOption = New-WinSCPSessionOption @WinSCPSessionParams
|
||||
$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 {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = 'Stop'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -352,11 +322,8 @@ function Connect-To {
|
||||
if (!($WinSCPSession.Opened)) {
|
||||
# Check the connection state and find out if the session is still open.
|
||||
$MessageParams = @{
|
||||
Message = (
|
||||
("Connection to {0} using Type {1} was established. " -f $RemoteHost, $Type) +
|
||||
"But now it seems to be lost!"
|
||||
)
|
||||
ErrorAction = 'Stop'
|
||||
Message = "Connection to {0} using Type {1} was established. But now it seems to be lost!" -f $RemoteHost, $Type
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -365,7 +332,7 @@ function Connect-To {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
Message = "Unable to connect to {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = 'Stop'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
|
@ -14,17 +14,8 @@ function Disconnect-From {
|
||||
same hostname.
|
||||
|
||||
.PARAMETER Type
|
||||
Specify the host type of the target. Currently implemented targets are:
|
||||
|
||||
- CiscoUcs
|
||||
- CiscoUcsCentral
|
||||
- FTP
|
||||
- NetAppFAS
|
||||
- VMware
|
||||
- CisServer
|
||||
- ExchangeHTTP
|
||||
- ExchangeHTTPS
|
||||
- SCP
|
||||
Specify the host type of the target. Currently implemented targets are: CiscoUcs, FTP, NetAppFAS, VMware,
|
||||
CisServer, ExchangeHTTP, ExchangeHTTPS, SCP.
|
||||
|
||||
.PARAMETER Force
|
||||
Force the disconnect, even if the disconnect would fail.
|
||||
@ -58,22 +49,24 @@ function Disconnect-From {
|
||||
|
||||
.EXAMPLE
|
||||
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()]
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||
'PSAvoidGlobalVars',
|
||||
'',
|
||||
Justification = 'Wrapping existing global vars from external modules'
|
||||
)]
|
||||
param (
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$RemoteHost,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateSet(
|
||||
'CiscoUcs',
|
||||
'CiscoUcsCentral',
|
||||
'FTP',
|
||||
'NetAppFAS',
|
||||
'VMware',
|
||||
@ -88,17 +81,14 @@ function Disconnect-From {
|
||||
[switch]$Force
|
||||
)
|
||||
|
||||
begin {}
|
||||
|
||||
process {
|
||||
switch -Regex ($Type) {
|
||||
"VMware" {
|
||||
try {
|
||||
if ($Force) {
|
||||
Disconnect-VIServer -Server $RemoteHost -Confirm:$false -ErrorAction 'Stop' -Force:$true
|
||||
Disconnect-VIServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop -Force:$true
|
||||
}
|
||||
else {
|
||||
Disconnect-VIServer -Server $RemoteHost -Confirm:$false -ErrorAction 'Stop'
|
||||
Disconnect-VIServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +96,7 @@ function Disconnect-From {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = 'Stop'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -114,10 +104,10 @@ function Disconnect-From {
|
||||
"CisServer" {
|
||||
try {
|
||||
if ($Force) {
|
||||
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction 'Stop' -Force:$true
|
||||
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop -Force:$true
|
||||
}
|
||||
else {
|
||||
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction 'Stop'
|
||||
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +115,7 @@ function Disconnect-From {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = 'Stop'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -137,8 +127,8 @@ function Disconnect-From {
|
||||
}
|
||||
else {
|
||||
$MessageParams = @{
|
||||
Message = 'There is no open WinSCP Session'
|
||||
ErrorAction = 'Stop'
|
||||
Message = "There is no open WinSCP Session"
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -148,10 +138,8 @@ function Disconnect-From {
|
||||
"NetAppFAS" {
|
||||
try {
|
||||
$MessageParams = @{
|
||||
Message = (
|
||||
"Setting {0} to `$null, which will disconnect NetAppFAS" -f $Global:CurrentNcController
|
||||
)
|
||||
ErrorAction = 'Continue'
|
||||
Message = "Setting {0} to `$null, which will disconnect NetAppFAS" -f $Global:CurrentNcController
|
||||
ErrorAction = "Continue"
|
||||
}
|
||||
Write-Verbose @MessageParams
|
||||
$Global:CurrentNcController = $null
|
||||
@ -161,7 +149,7 @@ function Disconnect-From {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = 'Stop'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -176,34 +164,20 @@ function Disconnect-From {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
Message = "Unable to disconnect from {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 disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = 'Stop'
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
|
||||
"ExchangeHTTP*" {
|
||||
try {
|
||||
Get-Variable -Name 'PSExchangeRemote' -Scope 'Global' -ErrorAction 'Stop'
|
||||
Remove-PSSession -Session $Global:PSExchangeRemote -ErrorAction 'Stop'
|
||||
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'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -214,8 +188,8 @@ function Disconnect-From {
|
||||
}
|
||||
else {
|
||||
$MessageParams = @{
|
||||
Message = 'There is no open WinSCP Session'
|
||||
ErrorAction = 'Stop'
|
||||
Message = "There is no open WinSCP Session"
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -224,10 +198,9 @@ function Disconnect-From {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = 'Stop'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,16 +21,24 @@ function Test-CSConnection {
|
||||
|
||||
.EXAMPLE
|
||||
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()]
|
||||
[OutputType([bool])]
|
||||
param (
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$RemoteHost,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[Parameter(Mandatory = $True)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[ValidateSet("CiscoUcs", "FTP", "NetAppFAS", "VMware")]
|
||||
[string]$Type
|
||||
|
@ -11,28 +11,22 @@
|
||||
<ListEntry>
|
||||
<ListItems>
|
||||
<ListItem>
|
||||
<Label>Country</Label>
|
||||
<ScriptBlock>$_.Subject.Country</ScriptBlock>
|
||||
<PropertyName>Country</PropertyName>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Label>State</Label>
|
||||
<ScriptBlock>$_.Subject.State</ScriptBlock>
|
||||
<PropertyName>State</PropertyName>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Label>City</Label>
|
||||
<ScriptBlock>$_.Subject.City</ScriptBlock>
|
||||
<PropertyName>City</PropertyName>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Label>Organization</Label>
|
||||
<ScriptBlock>$_.Subject.Organization</ScriptBlock>
|
||||
<PropertyName>Organization</PropertyName>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Label>OrganizationalUnitName</Label>
|
||||
<ScriptBlock>$_.Subject.OrganizationalUnitName</ScriptBlock>
|
||||
<PropertyName>OrganizationalUnitName</PropertyName>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Label>CommonName</Label>
|
||||
<ScriptBlock>$_.Subject.CommonName</ScriptBlock>
|
||||
<PropertyName>CommonName</PropertyName>
|
||||
</ListItem>
|
||||
</ListItems>
|
||||
</ListEntry>
|
||||
|
@ -29,25 +29,33 @@ function Get-CredentialStoreItem {
|
||||
|
||||
.EXAMPLE
|
||||
$myCreds = Get-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||
|
||||
.NOTES
|
||||
- File Name : Get-CredentialStoreItem.ps1
|
||||
- Author : Messing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
||||
[OutputType([PSCredential])]
|
||||
param (
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||
param(
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$RemoteHost,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Identifier,
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[switch]$Shared,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Path
|
||||
)
|
||||
@ -55,10 +63,10 @@ function Get-CredentialStoreItem {
|
||||
begin {
|
||||
# Set the CredentialStore for private, shared or custom mode.
|
||||
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
||||
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
||||
$Path = Get-DefaultCredentialStorePath
|
||||
}
|
||||
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||
elseif ($PSCmdlet.ParameterSetName -eq "Shared") {
|
||||
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
||||
$Path = Get-DefaultCredentialStorePath -Shared
|
||||
}
|
||||
@ -77,7 +85,7 @@ function Get-CredentialStoreItem {
|
||||
$CS = Get-CredentialStore -Shared -Path $Path
|
||||
$CSMembers = Get-Member -InputObject $CS
|
||||
# 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)) {
|
||||
if ($null -eq $CS.PfxCertificate) {
|
||||
$Cert = Get-CSCertificate -Type $CS.Type -Thumbprint $CS.Thumbprint
|
||||
}
|
||||
@ -98,16 +106,16 @@ function Get-CredentialStoreItem {
|
||||
}
|
||||
else {
|
||||
$MsgParams = @{
|
||||
ErrorAction = 'Stop'
|
||||
Message = 'Could not find credentials for the given remote host: {0}' -f $RemoteHost
|
||||
ErrorAction = "Stop"
|
||||
Message = "Could not find credentials for the given remote host: {0}" -f $RemoteHost
|
||||
}
|
||||
Write-Error @MsgParams
|
||||
}
|
||||
}
|
||||
else {
|
||||
$MsgParams = @{
|
||||
ErrorAction = 'Stop'
|
||||
Message = 'The given credential store ({0}) does not exist!' -f $Path
|
||||
ErrorAction = "Stop"
|
||||
Message = "The given credential store ({0}) does not exist!" -f $Path
|
||||
}
|
||||
Write-Error @MsgParams
|
||||
}
|
||||
|
@ -32,23 +32,26 @@ function New-CredentialStoreItem {
|
||||
[None]
|
||||
|
||||
.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')]
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||
'PSUseShouldProcessForStateChangingFunctions',
|
||||
'',
|
||||
Justification = 'Adds data into an existing object/file'
|
||||
)]
|
||||
param (
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
||||
param(
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$RemoteHost,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Identifier,
|
||||
|
||||
@ -56,10 +59,10 @@ function New-CredentialStoreItem {
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[PSCredential]$Credential,
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[switch]$Shared,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Path
|
||||
|
||||
@ -68,11 +71,11 @@ function New-CredentialStoreItem {
|
||||
|
||||
begin {
|
||||
# Set the CredentialStore for private, shared or custom mode.
|
||||
Write-Debug ('ParameterSetName: {0}' -f $PSCmdlet.ParameterSetName)
|
||||
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
||||
$Path = Get-DefaultCredentialStorePath
|
||||
}
|
||||
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||
elseif ($PSCmdlet.ParameterSetName -eq "Shared") {
|
||||
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
||||
$Path = Get-DefaultCredentialStorePath -Shared
|
||||
}
|
||||
@ -84,19 +87,19 @@ function New-CredentialStoreItem {
|
||||
if (-not(Test-CredentialStore -Shared -Path $Path)) {
|
||||
$MessageParams = @{
|
||||
Exception = [System.IO.FileNotFoundException]::new(
|
||||
'The given credential store ({0}) does not exist!' -f $Path
|
||||
'Could not add anything into the given CredentialStore.'
|
||||
)
|
||||
ErrorAction = 'Stop'
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
|
||||
$CSContent = Get-CredentialStore -Shared -Path $Path
|
||||
|
||||
$CurrentDate = Get-Date -Format 'u'
|
||||
$CurrentDate = Get-Date -UFormat "%Y-%m-%d %H:%M:%S"
|
||||
|
||||
if ($Identifier -ne '') {
|
||||
$CredentialName = $RemoteHost = '{0}/{1}' -f $Identifier, $RemoteHost
|
||||
if ($Identifier -ne "") {
|
||||
$CredentialName = $RemoteHost = "{0}/{1}" -f $Identifier, $RemoteHost
|
||||
}
|
||||
else {
|
||||
$CredentialName = $RemoteHost
|
||||
@ -114,9 +117,9 @@ function New-CredentialStoreItem {
|
||||
$Cert = Get-PfxCertificate -FilePath $CSContent.PfxCertificate -ErrorAction Stop
|
||||
}
|
||||
|
||||
if (Get-Member -InputObject $CSContent -Name $CredentialName -MemberType Properties) {
|
||||
if (Get-Member -InputObject $CSContent -Name $CredentialName -Membertype Properties) {
|
||||
$MessageParams = @{
|
||||
Message = 'The given host already exists. Nothing to do here.'
|
||||
Message = "The given host already exists. Nothing to do here."
|
||||
}
|
||||
Write-Warning @MessageParams
|
||||
}
|
||||
@ -128,27 +131,16 @@ function New-CredentialStoreItem {
|
||||
Password = ConvertFrom-SecureString -SecureString $Credential.Password -Key $RSAKey
|
||||
Created = $CurrentDate
|
||||
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))
|
||||
}
|
||||
$MemberParams = @{
|
||||
InputObject = $CSContent
|
||||
Name = $CredentialName
|
||||
MemberType = 'NoteProperty'
|
||||
Value = $CredentialHash
|
||||
}
|
||||
Add-Member @MemberParams
|
||||
Add-Member -InputObject $CSContent -Name $CredentialName -MemberType NoteProperty -Value $CredentialHash
|
||||
try {
|
||||
ConvertTo-Json -InputObject $CSContent | Out-File -FilePath $Path
|
||||
}
|
||||
catch {
|
||||
$MessageParams = @{
|
||||
Message = 'Could not add item into credential store!'
|
||||
ErrorAction = 'Stop'
|
||||
Message = "Couldn't add item into credential store!"
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -156,13 +148,15 @@ function New-CredentialStoreItem {
|
||||
}
|
||||
else {
|
||||
$MessageParams = @{
|
||||
Message = 'Please Provide at least a valid user!'
|
||||
ErrorAction = 'Stop'
|
||||
Message = "Please Provide at least a valid user!"
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
|
||||
end {}
|
||||
end {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,27 +37,30 @@ function Remove-CredentialStoreItem {
|
||||
|
||||
.EXAMPLE
|
||||
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')]
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||
'PSUseShouldProcessForStateChangingFunctions',
|
||||
'',
|
||||
Justification = 'Removes data from existing store.'
|
||||
)]
|
||||
param (
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
||||
param(
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[string]$RemoteHost,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[string]$Identifier,
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[switch]$Shared,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Path
|
||||
)
|
||||
@ -65,10 +68,10 @@ function Remove-CredentialStoreItem {
|
||||
begin {
|
||||
# Set the CredentialStore for private, shared or custom mode.
|
||||
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
||||
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
||||
$Path = Get-DefaultCredentialStorePath
|
||||
}
|
||||
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||
elseif ($PSCmdlet.ParameterSetName -eq "Shared") {
|
||||
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
||||
$Path = Get-DefaultCredentialStorePath -Shared
|
||||
}
|
||||
@ -79,8 +82,8 @@ function Remove-CredentialStoreItem {
|
||||
# Lets do a quick test on the given CredentialStore.
|
||||
if (-not(Test-CredentialStore -Shared -Path $Path)) {
|
||||
$MessageParams = @{
|
||||
Message = 'Could not add anything into the given CredentialStore.'
|
||||
ErrorAction = 'Stop'
|
||||
Message = "Could not add anything into the given CredentialStore."
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
@ -95,14 +98,14 @@ function Remove-CredentialStoreItem {
|
||||
$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.
|
||||
$CSContent.PSObject.Properties.Remove($CredentialName)
|
||||
ConvertTo-Json -InputObject $CSContent -Depth 5 | Out-File -FilePath $Path -Encoding utf8
|
||||
}
|
||||
else {
|
||||
$MessageParams = @{
|
||||
Message = 'The given CredentialStoreItem does not exist.'
|
||||
Message = "The given CredentialStoreItem does not exist."
|
||||
}
|
||||
Write-Warning @MessageParams
|
||||
}
|
||||
|
@ -1,130 +0,0 @@
|
||||
[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'
|
||||
|
||||
}
|
@ -13,7 +13,7 @@ function Set-CredentialStoreItem {
|
||||
Specify the host you for which you would like to change the credentials.
|
||||
|
||||
.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.
|
||||
|
||||
.PARAMETER Shared
|
||||
@ -30,46 +30,49 @@ function Set-CredentialStoreItem {
|
||||
[None]
|
||||
|
||||
.EXAMPLE
|
||||
Set-CredentialStoreItem -Path 'C:\TMP\mystore.json' -RemoteHost 'esx01.myside.local'
|
||||
Set-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||
|
||||
.EXAMPLE
|
||||
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
|
||||
|
||||
.NOTES
|
||||
- File Name : Set-CredentialStoreItem.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
|
||||
'PSUseShouldProcessForStateChangingFunctions',
|
||||
'',
|
||||
Justification = 'Updates existing credential object.'
|
||||
)]
|
||||
param (
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
||||
param(
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[string]$RemoteHost,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[string]$Identifier,
|
||||
|
||||
[Parameter(Mandatory = $false, ValueFromPipeline = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[PSCredential]$Credential,
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[switch]$Shared,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Path
|
||||
)
|
||||
|
||||
begin {
|
||||
# Set the CredentialStore for private, shared or custom mode.
|
||||
Write-Debug ('ParameterSetName: {0}' -f $PSCmdlet.ParameterSetName)
|
||||
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
||||
$Path = Get-DefaultCredentialStorePath
|
||||
}
|
||||
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||
elseif ($PSCmdlet.ParameterSetName -eq "Shared") {
|
||||
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
||||
$Path = Get-DefaultCredentialStorePath -Shared
|
||||
}
|
||||
@ -77,52 +80,32 @@ function Set-CredentialStoreItem {
|
||||
}
|
||||
|
||||
process {
|
||||
# Define the default splatting.
|
||||
$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)) {
|
||||
# Lets do a quick test on the given CredentialStore.
|
||||
if (-not(Test-CredentialStore -Shared -Path $Path)) {
|
||||
$MessageParams = @{
|
||||
Message = ('The given CredentialStore ({0}) does no exist.' -f $Path)
|
||||
ErrorAction = 'Stop'
|
||||
Message = "Could not add anything into the given CredentailStore."
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
|
||||
# Read the file content based on the given ParameterSetName
|
||||
$CSContent = Get-CredentialStore @DefaultSplatting
|
||||
$CSContent = Get-CredentialStore -Shared -Path $Path
|
||||
|
||||
# Get a formatted current date for the last update time of the Item.
|
||||
$CurrentDate = Get-Date -Format 'u'
|
||||
$CurrentDate = Get-Date -UFormat "%Y-%m-%d %H:%M:%S"
|
||||
|
||||
# Check if the user supplied an identifier. If so, we need to mangle the CredentialName, as that's where
|
||||
# the identifier is actually added.
|
||||
if ($Identifier -ne '') {
|
||||
$CredentialName = $RemoteHost = '{0}/{1}' -f $Identifier, $RemoteHost
|
||||
if ($Identifier -ne "") {
|
||||
$CredentialName = $RemoteHost = "{0}/{1}" -f $Identifier, $RemoteHost
|
||||
}
|
||||
else {
|
||||
$CredentialName = $RemoteHost
|
||||
}
|
||||
|
||||
# If the user didn't supply a CredentialObject, we need to prompt for it.
|
||||
if (-not($Credential)) {
|
||||
$Credential = Get-Credential -Message $CredentialName
|
||||
}
|
||||
|
||||
# If the username isn't empty, we ca go ahead and update the entry.
|
||||
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 ($Credential.UserName) {
|
||||
if ($null -eq $CSContent.PfxCertificate) {
|
||||
$Cert = Get-CSCertificate -Type $CSContent.Type -Thumbprint $CSContent.Thumbprint
|
||||
}
|
||||
@ -130,18 +113,10 @@ function Set-CredentialStoreItem {
|
||||
$Cert = Get-PfxCertificate -FilePath $CSContent.PfxCertificate -ErrorAction Stop
|
||||
}
|
||||
|
||||
# Now locate the Item.
|
||||
if (Get-Member -InputObject $CSContent -Name $CredentialName -MemberType Properties) {
|
||||
# Get a random AES key for the entry.
|
||||
if (Get-Member -InputObject $CSContent -Name $CredentialName -Membertype Properties) {
|
||||
$RSAKey = Get-RandomAESKey
|
||||
$CSContent.$CredentialName.User = $Credential.UserName
|
||||
$ConvertParams = @{
|
||||
SecureString = $Credential.Password
|
||||
Key = $RSAKey
|
||||
}
|
||||
|
||||
# Now create a updated item containing the updated credentials.
|
||||
$CSContent.$CredentialName.Password = ConvertFrom-SecureString @ConvertParams
|
||||
$CSContent.$CredentialName.Password = ConvertFrom-SecureString -SecureString $Credential.Password -Key $RSAKey
|
||||
$CSContent.$CredentialName.LastChange = $CurrentDate
|
||||
$CSContent.$CredentialName.EncryptedKey = [Convert]::ToBase64String(
|
||||
$Cert.PublicKey.Key.Encrypt(
|
||||
@ -149,18 +124,13 @@ function Set-CredentialStoreItem {
|
||||
[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
|
||||
}
|
||||
else {
|
||||
Write-Warning -Message ('Unable to locate CredentialStoreItem for {0}' -f $CredentialName)
|
||||
}
|
||||
}
|
||||
else {
|
||||
Else {
|
||||
$MessageParams = @{
|
||||
Message = 'Please Provide at least a valid user!'
|
||||
ErrorAction = 'Stop'
|
||||
Message = "Please Provide at least a valid user!"
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
|
@ -7,10 +7,6 @@ function Test-CredentialStoreItem {
|
||||
Use this cmdlet for basic checks with a single item. Check the item first with this function before
|
||||
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
|
||||
Define a custom credential store you try to read from. Without the `-Path` parameter
|
||||
`Test-CredentialStoreItem` tries to read from the default private store.
|
||||
@ -33,19 +29,26 @@ function Test-CredentialStoreItem {
|
||||
[None]
|
||||
|
||||
.EXAMPLE
|
||||
if (Test-CredentialStoreItem -RemoteHost 'Default') {
|
||||
Get-CredentialStoreItem -RemoteHost 'Default'
|
||||
If (Test-CredentialStoreItem -RemoteHost "Default") {
|
||||
Get-CredentialStoreItem -RemoteHost "Default"
|
||||
}
|
||||
else {
|
||||
Write-Warning ('The given Remote Host {0} does not exist in the credential Store!' -f $RemoteHost)
|
||||
Else {
|
||||
Write-Warning ("The given Remote Host {0} does not exist in the credential Store!" -f $RemoteHost)
|
||||
}
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||
[OutputType([bool])]
|
||||
param (
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[string]$Path = '{0}\PSCredentialStore\CredentialStore.json' -f $env:ProgramData,
|
||||
.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])]
|
||||
param(
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[string]$Path = "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
@ -55,17 +58,17 @@ function Test-CredentialStoreItem {
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Identifier,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[switch]$Shared
|
||||
)
|
||||
|
||||
begin {
|
||||
# Set the CredentialStore for private, shared or custom mode.
|
||||
Write-Debug ('ParameterSetName: {0}' -f $PSCmdlet.ParameterSetName)
|
||||
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
||||
$Path = Get-DefaultCredentialStorePath
|
||||
}
|
||||
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||
elseif ($PSCmdlet.ParameterSetName -eq "Shared") {
|
||||
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
||||
$Path = Get-DefaultCredentialStorePath -Shared
|
||||
}
|
||||
@ -73,8 +76,8 @@ function Test-CredentialStoreItem {
|
||||
}
|
||||
|
||||
process {
|
||||
if ($Identifier -ne '') {
|
||||
$CredentialName = $RemoteHost = '{0}/{1}' -f $Identifier, $RemoteHost
|
||||
if ($Identifier -ne "") {
|
||||
$CredentialName = $RemoteHost = "{0}/{1}" -f $Identifier, $RemoteHost
|
||||
}
|
||||
else {
|
||||
$CredentialName = $RemoteHost
|
||||
@ -83,7 +86,7 @@ function Test-CredentialStoreItem {
|
||||
if (Test-CredentialStore -Shared -Path $Path) {
|
||||
$CS = Get-CredentialStore -Shared -Path $Path
|
||||
$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
|
||||
}
|
||||
else {
|
||||
@ -92,13 +95,15 @@ function Test-CredentialStoreItem {
|
||||
}
|
||||
else {
|
||||
$MsgParams = @{
|
||||
Message = 'The given credential store ({0}) does not exist!' -f $Path
|
||||
ErrorAction = "Stop"
|
||||
Message = "The given credential store ({0}) does not exist!" -f $Path
|
||||
}
|
||||
Write-Warning @MsgParams
|
||||
return $false
|
||||
Write-Error @MsgParams
|
||||
}
|
||||
}
|
||||
|
||||
end {}
|
||||
end {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
#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.
|
||||
RootModule = 'ModuleRoot.psm1'
|
||||
RootModule = 'PSCredentialStore.psm1'
|
||||
|
||||
# Version number of this module.
|
||||
ModuleVersion = '0.0.9999'
|
||||
@ -19,10 +19,10 @@
|
||||
CompanyName = ''
|
||||
|
||||
# Copyright statement for this module
|
||||
Copyright = '(c) OCram85. All rights reserved.'
|
||||
Copyright = '(c) 2020 OCram85. All rights reserved.'
|
||||
|
||||
# Description of the functionality provided by this module
|
||||
Description = 'A simple cross-platform credential manager for PSCredential objects.'
|
||||
Description = 'A simple credential manager to store and reuse multiple credential objects.'
|
||||
|
||||
# Minimum version of the PowerShell engine required by this module
|
||||
PowerShellVersion = '5.1'
|
||||
@ -33,12 +33,10 @@
|
||||
# Minimum version of the PowerShell host required by this module
|
||||
# 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 = ''
|
||||
|
||||
# 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 = ''
|
||||
|
||||
# Processor architecture (None, X86, Amd64) required by this module
|
||||
@ -65,8 +63,7 @@
|
||||
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
|
||||
# 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 = @(
|
||||
# Certificate
|
||||
'Get-CSCertificate',
|
||||
@ -95,15 +92,13 @@
|
||||
'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 = @()
|
||||
|
||||
# Variables to export from this module
|
||||
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 = @()
|
||||
|
||||
# DSC resources to export from this module
|
||||
@ -115,8 +110,7 @@
|
||||
# List of all files packaged with this module
|
||||
# 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 = @{
|
||||
|
||||
PSData = @{
|
||||
@ -125,16 +119,16 @@
|
||||
Tags = 'CredentialStore', 'CredentialManager'
|
||||
|
||||
# A URL to the license for this module.
|
||||
LicenseUri = 'https://gitea.ocram85.com/OCram85/PSCredentialStore/raw/branch/master/LICENSE'
|
||||
LicenseUri = 'https://github.com/OCram85/PSCredentialStore/blob/master/LICENSE'
|
||||
|
||||
# A URL to the main website for this project.
|
||||
ProjectUri = 'https://gitea.ocram85.com/OCram85/PSCredentialStore'
|
||||
ProjectUri = 'https://github.com/OCram85/PSCredentialStore'
|
||||
|
||||
# A URL to an icon representing this module.
|
||||
IconUri = 'https://gitea.ocram85.com/OCram85/PSCredentialStore/raw/branch/master/assets/logo256.png'
|
||||
IconUri = 'https://raw.githubusercontent.com/OCram85/PSCredentialStore/master/assets/logo256.png'
|
||||
|
||||
# ReleaseNotes of this module
|
||||
ReleaseNotes = 'See https://gitea.ocram85.com/OCram85/PSCredentialStore/releases page for details.'
|
||||
ReleaseNotes = 'See https://github.com/OCram85/PSCredentialStore/releases page for details.'
|
||||
|
||||
# Prerelease string of this module
|
||||
#Prerelease = 'preview'
|
||||
@ -143,42 +137,16 @@
|
||||
# RequireLicenseAcceptance = $false
|
||||
|
||||
# External dependent modules of this module
|
||||
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'
|
||||
}
|
||||
)
|
||||
# ExternalModuleDependencies = @()
|
||||
|
||||
} # End of PSData hashtable
|
||||
|
||||
} # End of PrivateData hashtable
|
||||
|
||||
# HelpInfo URI of this module
|
||||
HelpInfoURI = 'https://gitea.ocram85.com/OCram85/PSCredentialStore'
|
||||
HelpInfoURI = 'https://github.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 = ''
|
||||
|
||||
}
|
||||
|
18
src/PSCredentialStore.psm1
Normal file
18
src/PSCredentialStore.psm1
Normal file
@ -0,0 +1,18 @@
|
||||
#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
|
@ -1,12 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@ -23,11 +23,18 @@ function Get-CSPfxCertificate {
|
||||
|
||||
.EXAMPLE
|
||||
Get-CSPfxCertificate -Thumbprint '12345678' -StoreName 'My' -StoreLocation 'CurrentUser'
|
||||
#>
|
||||
|
||||
.NOTES
|
||||
- File Name : Get-CSPfxCertificate.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
[OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2])]
|
||||
param (
|
||||
param(
|
||||
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$Thumbprint,
|
||||
|
@ -14,16 +14,23 @@ function Get-DefaultCredentialStorePath {
|
||||
|
||||
.EXAMPLE
|
||||
$Path = Get-DefaultCredentialStorePath
|
||||
#>
|
||||
|
||||
.NOTES
|
||||
- File Name : Get-DefaultCredentialStorePath.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
[OutputType([string])]
|
||||
param (
|
||||
param(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[switch]$Shared
|
||||
)
|
||||
|
||||
begin {}
|
||||
begin { }
|
||||
|
||||
process {
|
||||
if ($Shared.IsPresent) {
|
||||
@ -33,11 +40,7 @@ function Get-DefaultCredentialStorePath {
|
||||
if ($IsMacOS) {
|
||||
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'
|
||||
}
|
||||
}
|
||||
@ -48,15 +51,11 @@ function Get-DefaultCredentialStorePath {
|
||||
if ($IsMacOS) {
|
||||
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'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end {}
|
||||
end { }
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
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,16 +6,24 @@ function Get-ModuleBase {
|
||||
.DESCRIPTION
|
||||
This is just a wrapper for enabling pester tests.
|
||||
|
||||
|
||||
.OUTPUTS
|
||||
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()]
|
||||
[OutputType([string])]
|
||||
param ()
|
||||
begin {}
|
||||
[OutputType()]
|
||||
param()
|
||||
begin { }
|
||||
process {
|
||||
return $MyInvocation.MyCommand.Module.ModuleBase
|
||||
}
|
||||
end {}
|
||||
end { }
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
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,13 +14,21 @@ function Get-RandomAESKey {
|
||||
|
||||
.EXAMPLE
|
||||
.\Get-RandomAESKey
|
||||
|
||||
.NOTES
|
||||
- File Name : Get-RandomAESKey.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
[OutputType([byte[]])]
|
||||
param ()
|
||||
param()
|
||||
|
||||
begin {}
|
||||
begin { }
|
||||
|
||||
process {
|
||||
$key = [byte[]]::new(32)
|
||||
@ -32,5 +40,5 @@ function Get-RandomAESKey {
|
||||
}
|
||||
|
||||
}
|
||||
end {}
|
||||
end { }
|
||||
}
|
||||
|
@ -13,14 +13,21 @@ function Get-TempDir {
|
||||
|
||||
.EXAMPLE
|
||||
Get-TempDir
|
||||
#>
|
||||
|
||||
.NOTES
|
||||
- File Name : Get-TempDir.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
[OutputType([string])]
|
||||
param ()
|
||||
|
||||
begin {}
|
||||
param()
|
||||
begin {
|
||||
|
||||
}
|
||||
process {
|
||||
if ($IsLinux) {
|
||||
return (Resolve-Path -Path '/tmp/').Path
|
||||
@ -28,14 +35,10 @@ function Get-TempDir {
|
||||
if ($IsMacOS) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
end {}
|
||||
end {
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ function Import-CSPfxCertificate {
|
||||
|
||||
.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.
|
||||
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.
|
||||
@ -22,10 +22,18 @@ function Import-CSPfxCertificate {
|
||||
|
||||
.EXAMPLE
|
||||
Import-CSPfxCertificate -Path (Join-Path -Path $Env:APPDATA -ChildPath '/PSCredentialStore.pfx')
|
||||
#>
|
||||
|
||||
.NOTES
|
||||
File Name : Import-CSPfxCertificate.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[OutputType()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Path,
|
||||
@ -60,7 +68,6 @@ function Import-CSPfxCertificate {
|
||||
)]
|
||||
[string]$OpenFlags = 'ReadWrite'
|
||||
)
|
||||
|
||||
begin {
|
||||
$Store = [System.Security.Cryptography.X509Certificates.X509Store]::new($StoreName, $StoreLocation)
|
||||
try {
|
||||
@ -70,7 +77,6 @@ function Import-CSPfxCertificate {
|
||||
$_.Exception.Message | Write-Error -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
try {
|
||||
$cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new(
|
||||
@ -83,9 +89,7 @@ function Import-CSPfxCertificate {
|
||||
)
|
||||
|
||||
if (Test-CSPfxCertificate -Thumbprint $cert.Thumbprint) {
|
||||
Write-Warning -Message (
|
||||
'The certificate with thumbprint {0} is already present!' -f $cert.Thumbprint
|
||||
)
|
||||
Write-Warning -Message ('The certificate with thumbprint {0} is already present!' -f $cert.Thumbprint)
|
||||
}
|
||||
else {
|
||||
$Store.Add($cert)
|
||||
|
91
src/Private/Resolve-Dependency.ps1
Normal file
91
src/Private/Resolve-Dependency.ps1
Normal file
@ -0,0 +1,91 @@
|
||||
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 {
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@ -23,11 +23,18 @@ function Test-CSPfxCertificate {
|
||||
|
||||
.EXAMPLE
|
||||
Test-CSPfxCertificate -Thumbprint '12345678' -StoreName 'My' -StoreLocation 'CurrentUser'
|
||||
#>
|
||||
|
||||
.NOTES
|
||||
File Name : Test-CSPfxCertificate.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
[OutputType([bool])]
|
||||
param (
|
||||
param(
|
||||
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Thumbprint,
|
||||
@ -64,8 +71,6 @@ function Test-CSPfxCertificate {
|
||||
}
|
||||
|
||||
process {
|
||||
# Script analyzer issue (unused var) workaround
|
||||
$null = $Thumbprint
|
||||
$Cert = $Store.Certificates | Where-Object { $_.Thumbprint -eq $Thumbprint }
|
||||
|
||||
if ($null -eq $Cert) {
|
||||
|
@ -32,11 +32,18 @@ function Test-Module {
|
||||
|
||||
.EXAMPLE
|
||||
.\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])]
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Name,
|
||||
@ -49,8 +56,7 @@ Could not find the required {0} called {1}. Please install the required {0} to r
|
||||
[Parameter(Mandatory = $false)]
|
||||
[switch]$StopIfFails
|
||||
)
|
||||
|
||||
begin {}
|
||||
begin { }
|
||||
|
||||
process {
|
||||
$Message = $MessagePattern -f $Type, $Name
|
||||
@ -67,5 +73,5 @@ Could not find the required {0} called {1}. Please install the required {0} to r
|
||||
}
|
||||
}
|
||||
|
||||
end {}
|
||||
end { }
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
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,28 +23,35 @@ function Get-CredentialStore {
|
||||
|
||||
.EXAMPLE
|
||||
$CSContent = Get-CredentialStore -Path "C:\TMP\mystore.json"
|
||||
|
||||
.NOTES
|
||||
- File Name : Get-CredentialStore.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||
[OutputType('PSCredentialStore.Store')]
|
||||
param (
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
||||
[OutputType("PSCredentialStore.Store")]
|
||||
param(
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
|
||||
[string]$Path,
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[switch]$Shared
|
||||
)
|
||||
|
||||
begin {}
|
||||
begin { }
|
||||
|
||||
process {
|
||||
# Set the CredentialStore for private, shared or custom mode.
|
||||
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
||||
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
||||
$Path = Get-DefaultCredentialStorePath
|
||||
}
|
||||
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||
elseif ($PSCmdlet.ParameterSetName -eq "Shared") {
|
||||
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
||||
$Path = Get-DefaultCredentialStorePath -Shared
|
||||
}
|
||||
@ -54,26 +61,26 @@ function Get-CredentialStore {
|
||||
try {
|
||||
$FileContent = Get-Content -Path $Path -Raw
|
||||
$CS = ConvertFrom-Json $FileContent
|
||||
$CS.PSObject.TypeNames.Insert(0, 'PSCredentialStore.Store')
|
||||
Write-Output $CS
|
||||
$CS.PSObject.TypeNames.Insert(0, "PSCredentialStore.Store")
|
||||
return $CS
|
||||
}
|
||||
catch [System.Exception] {
|
||||
$MessageParams = @{
|
||||
Message = 'Unknown CredentialStore format. Invalid JSON file.'
|
||||
ErrorAction = 'Stop'
|
||||
Message = "Unknown CredentialStore format. Invalid JSON file."
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
else {
|
||||
$MessageParams = @{
|
||||
Message = 'Could not find the CredentialStore.'
|
||||
ErrorAction = 'Stop'
|
||||
Message = "Could not find the CredentialStore."
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
|
||||
end {}
|
||||
end { }
|
||||
|
||||
}
|
||||
|
@ -1,141 +0,0 @@
|
||||
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"
|
||||
|
||||
}
|
@ -19,13 +19,13 @@ function New-CredentialStore {
|
||||
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.
|
||||
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.
|
||||
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
|
||||
[None]
|
||||
@ -49,38 +49,49 @@ function New-CredentialStore {
|
||||
.EXAMPLE
|
||||
New-CredentialStore -Shared -Path "C:\TMP\CredentialStore.json"
|
||||
# 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')]
|
||||
[OutputType('PSCredentialStore.Store')]
|
||||
param (
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = "Private")]
|
||||
[OutputType("PSCredentialStore.Store")]
|
||||
param(
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[switch]$Shared,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[System.IO.FileInfo]$Path,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[switch]$Force,
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[Switch]$Force,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[switch]$PassThru,
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[Switch]$PassThru,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[switch]$SkipPFXCertCreation,
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[Switch]$SkipPFXCertCreation,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Private')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
[switch]$UseCertStore
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[Switch]$UseCertStore
|
||||
)
|
||||
|
||||
begin {
|
||||
# Lets get the current Date in a human readable format.
|
||||
$CurrentDate = Get-Date -Format 'u'
|
||||
$CurrentDate = Get-Date -UFormat "%Y-%m-%d %H:%M:%S"
|
||||
|
||||
# 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
|
||||
if ($PSCmdlet.MyInvocation.BoundParameters.ContainsKey('Path')) {
|
||||
@ -88,8 +99,7 @@ function New-CredentialStore {
|
||||
$ErrorParams = @{
|
||||
ErrorAction = 'Stop'
|
||||
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
|
||||
@ -98,7 +108,7 @@ function New-CredentialStore {
|
||||
$ErrorParams = @{
|
||||
ErrorAction = 'Stop'
|
||||
Exception = [System.IO.InvalidDataException]::new(
|
||||
'Your provided path does not contain the required file extension .json!'
|
||||
'Your provided path does not contain the required file extension .json !'
|
||||
)
|
||||
}
|
||||
Write-Error @ErrorParams
|
||||
@ -109,17 +119,17 @@ function New-CredentialStore {
|
||||
process {
|
||||
# Set the CredentialStore for private, shared or custom mode.
|
||||
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
||||
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
||||
$Path = Get-DefaultCredentialStorePath
|
||||
}
|
||||
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||
elseif ($PSCmdlet.ParameterSetName -eq "Shared") {
|
||||
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
||||
$Path = Get-DefaultCredentialStorePath -Shared
|
||||
}
|
||||
}
|
||||
|
||||
# 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)) {
|
||||
$ErrorParams = @{
|
||||
ErrorAction = 'Stop'
|
||||
@ -201,11 +211,11 @@ function New-CredentialStore {
|
||||
Type = $null
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||
$ObjProperties.Type = 'Shared'
|
||||
if ($PSCmdlet.ParameterSetName -eq "Shared") {
|
||||
$ObjProperties.Type = "Shared"
|
||||
}
|
||||
else {
|
||||
$ObjProperties.Type = 'Private'
|
||||
$ObjProperties.Type = "Private"
|
||||
}
|
||||
|
||||
if (! $SkipPFXCertCreation.IsPresent) {
|
||||
@ -243,5 +253,6 @@ function New-CredentialStore {
|
||||
}
|
||||
}
|
||||
|
||||
end {}
|
||||
end {
|
||||
}
|
||||
}
|
||||
|
@ -16,27 +16,36 @@ function Test-CredentialStore {
|
||||
|
||||
.EXAMPLE
|
||||
Test-CredentialStore -eq $true
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName = 'Private')]
|
||||
[OutputType([bool])]
|
||||
param (
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'Shared')]
|
||||
.NOTES
|
||||
- File Name : Test-CredentialStore.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
||||
param(
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[string]$Path,
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Shared')]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[switch]$Shared
|
||||
)
|
||||
|
||||
begin {}
|
||||
begin {
|
||||
# Set latest Credential Store version
|
||||
#Set-Variable -Name "CSVersion" -Value "2.0.0" -Option Constant
|
||||
}
|
||||
|
||||
process {
|
||||
# Set the CredentialStore for private, shared or custom mode.
|
||||
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
||||
if ($PSCmdlet.ParameterSetName -eq 'Private') {
|
||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
||||
$Path = Get-DefaultCredentialStorePath
|
||||
}
|
||||
elseif ($PSCmdlet.ParameterSetName -eq 'Shared') {
|
||||
elseif ($PSCmdlet.ParameterSetName -eq "Shared") {
|
||||
if (!($PSBoundParameters.ContainsKey('Path'))) {
|
||||
$Path = Get-DefaultCredentialStorePath -Shared
|
||||
}
|
||||
@ -44,15 +53,15 @@ function Test-CredentialStore {
|
||||
Write-Verbose -Message ("Path is: {0}" -f $Path)
|
||||
|
||||
if (Test-Path $Path) {
|
||||
Write-Verbose 'CredentialStore in given path found.'
|
||||
Write-Output $true
|
||||
Write-Verbose "CredentialStore in given path found."
|
||||
return $true
|
||||
}
|
||||
else {
|
||||
Write-Verbose 'The given CredentialStore does not exist!'
|
||||
Write-Output $false
|
||||
Write-Verbose "The given CredentialStore does not exist!"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
end {}
|
||||
end { }
|
||||
|
||||
}
|
||||
|
BIN
src/Vendor/libressl/openssl.exe
(Stored with Git LFS)
vendored
BIN
src/Vendor/libressl/openssl.exe
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
src/Vendor/libressl255/libcrypto-41.dll
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/libcrypto-41.dll
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/libcrypto-41.exp
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/libcrypto-41.exp
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/libcrypto-41.lib
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/libcrypto-41.lib
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/libcrypto-41.pdb
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/libcrypto-41.pdb
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/libssl-43.dll
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/libssl-43.dll
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/libssl-43.exp
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/libssl-43.exp
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/libssl-43.lib
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/libssl-43.lib
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/libssl-43.pdb
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/libssl-43.pdb
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/libtls-15.dll
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/libtls-15.dll
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/libtls-15.exp
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/libtls-15.exp
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/libtls-15.lib
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/libtls-15.lib
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/libtls-15.pdb
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/libtls-15.pdb
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/ocspcheck.exe
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/ocspcheck.exe
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
src/Vendor/libressl255/openssl.exe
(Stored with Git LFS)
vendored
Normal file
BIN
src/Vendor/libressl255/openssl.exe
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
17
tests/00_BasicModule.Tests.ps1
Normal file
17
tests/00_BasicModule.Tests.ps1
Normal file
@ -0,0 +1,17 @@
|
||||
$RepoRoot = (Get-Item -Path (Get-GitDirectory) -Force).Parent | Select-Object -ExpandProperty 'FullName'
|
||||
Write-Verbose -Message ('RepoRoot: {0}' -f $RepoRoot) -Verbose
|
||||
|
||||
$ManifestFilePath = Join-Path -Path $RepoRoot -ChildPath '/src/PSCredentialStore.psd1'
|
||||
Write-Verbose -Message ("ManifestFilePath: {0}" -f $ManifestFilePath) -Verbose
|
||||
Describe "Pre-Flight module tests" {
|
||||
Context "Manifest file related" {
|
||||
It "Test the parsed file itself" {
|
||||
{ Test-ModuleManifest -Path $ManifestFilePath -Verbose } | Should -Not -Throw
|
||||
}
|
||||
}
|
||||
Context "Module consistency tests" {
|
||||
It "Importing should work" {
|
||||
{ Import-Module -Name $ManifestFilePath -Global -Force -Verbose } | Should -Not -Throw
|
||||
}
|
||||
}
|
||||
}
|
7
tests/Certificate/50_New-CSCertAttribute.Tests.ps1
Normal file
7
tests/Certificate/50_New-CSCertAttribute.Tests.ps1
Normal file
@ -0,0 +1,7 @@
|
||||
Describe "New-CSCertAttribute" {
|
||||
Context "Basis Tests" {
|
||||
It "Test1: Should not throw " {
|
||||
{ New-CSCertAttribute -Country 'DE' -State 'BW' -City 'KA' -Organization 'IT' -OrganizationalUnitName'' -CommonName 'Mycert' } | Should -Not -Throw
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user