Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
8d55f2d6fd | |||
ce823d4564 | |||
2422afbd8f |
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@ -28,7 +28,7 @@
|
||||
"taskName": "Test",
|
||||
"suppressTaskName": true,
|
||||
"args": [
|
||||
"Write-Host 'Invoking Pester...'; $ProgressPreference = 'SilentlyContinue'; Invoke-Pester -Script '.\\tests\\*' -EnableExit $flase -PesterOption @{IncludeVSCodeMarker=$true};",
|
||||
"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.' }"
|
||||
],
|
||||
"problemMatcher": "$pester",
|
||||
|
11
README.md
11
README.md
@ -1,6 +1,6 @@
|
||||
[](https://ci.appveyor.com/project/OCram85/pscredentialstore/branch/master)
|
||||
[](https://ci.appveyor.com/project/OCram85/pscredentialstore/branch/master/tests)
|
||||
[](https://coveralls.io/github/OCram85/PSCredentialStorebranch=master)
|
||||
[](https://coveralls.io/github/OCram85/PSCredentialStore?branch=master)
|
||||
[](https://www.powershellgallery.com/packages/PSCredentialStore)
|
||||
[](https://www.powershellgallery.com/packages/PSCredentialStore)
|
||||
|
||||
@ -20,7 +20,8 @@ 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.
|
||||
|
||||
For more details read the [about_PSCredentialStore](/src/en-US/about_PSCredential.help.txt) page.
|
||||
For more details read the [about_PSCredentialStore](/docs/about_PSCredentialStore.md) page on github or via CLI with
|
||||
`Get-Help about_PSCredentialStore`.
|
||||
|
||||
Installation
|
||||
============
|
||||
@ -80,6 +81,12 @@ If you have already installed the underlying framework / modules, you can connec
|
||||
* Required Modules: [`VMware.VimAutomation.Core`](https://www.powershellgallery.com/packages/VMware.PowerCLI)
|
||||
* **CisServer** - Establish a connection to the CisServer Service on vCenter Host.
|
||||
* Required Modules: [`VMware.VimAutomation.Cis.Core`](https://www.powershellgallery.com/packages/VMware.PowerCLI)
|
||||
* **ExchangeHTTP** - Establish a remote connection with an Exchange endpoint via http.
|
||||
* Requires PowerShell remoting
|
||||
* **ExchangeHTTPS** - Establish a remote connection with an Exchange endpoint via https.
|
||||
* Requires PowerShell remoting
|
||||
* **SCP** - Establish a SCP connection.
|
||||
* Required Modules: [`WinSCP`](https://www.powershellgallery.com/packages/WinSCP)
|
||||
|
||||
Here are some basic examples:
|
||||
|
||||
|
31
appveyor.yml
31
appveyor.yml
@ -1,10 +1,10 @@
|
||||
version: 0.2.0.{build}
|
||||
version: 0.2.1.{build}
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- dev
|
||||
- debug
|
||||
#branches:
|
||||
# only:
|
||||
# - master
|
||||
# - dev
|
||||
# - debug
|
||||
|
||||
skip_tags: true
|
||||
|
||||
@ -13,9 +13,14 @@ skip_tags: true
|
||||
image: Visual Studio 2017
|
||||
|
||||
# Install pester module and init the Appveyor support.
|
||||
|
||||
# Enable RDP connection for debugging
|
||||
#init:
|
||||
# - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
|
||||
install:
|
||||
- ps: Import-Module .\tools\AppVeyor.psm1
|
||||
- ps: Invoke-InstallDependencies -Verbose
|
||||
- ps: Invoke-InstallDependencies
|
||||
|
||||
environment:
|
||||
NuGetToken:
|
||||
@ -33,7 +38,13 @@ build_script:
|
||||
|
||||
test_script:
|
||||
- ps: Invoke-AppVeyorTests
|
||||
- ps: Invoke-CoverageReport
|
||||
- ps: |
|
||||
if ($null -ne $Env:CoverallsToken) {
|
||||
Invoke-CoverageReport
|
||||
}
|
||||
else {
|
||||
Write-Warning "No CoverallsToken found. This build seems to be triggered by a PR. Skipping this step..."
|
||||
}
|
||||
|
||||
deploy:
|
||||
#- provider: GitHub
|
||||
@ -55,3 +66,7 @@ deploy:
|
||||
|
||||
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'))
|
||||
|
@ -29,51 +29,56 @@ Establish a connection to the selected host using a stored CredentialStoreItem.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
### EXAMPLE 1
|
||||
```
|
||||
Connect-To -RemoteHost "ucs.myside.local" -Type CiscoUcs
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 2 --------------------------
|
||||
### EXAMPLE 2
|
||||
```
|
||||
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 3 --------------------------
|
||||
### EXAMPLE 3
|
||||
```
|
||||
Connect-To -RemoteHost "fas.myside.local" -Type NetAppFAS
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 4 --------------------------
|
||||
### EXAMPLE 4
|
||||
```
|
||||
Connect-To -RemoteHost "esx01.myside.local" -Type VMware
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 5 --------------------------
|
||||
### EXAMPLE 5
|
||||
```
|
||||
Connect-To -RemoteHost "vCenter.myside.local" -Type CisServer
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 6 --------------------------
|
||||
### EXAMPLE 6
|
||||
```
|
||||
$MyCreds = Get-Credential
|
||||
Connect-To -RemoteHost "exchange01.myside.local" -Type ExchangeHTTP
|
||||
```
|
||||
|
||||
Connect-To -RemoteHost "vcr01.myside.local" -Type VMware -Credentials $MyCreds
|
||||
Get-VM -Name "*vlm*" | Select-Object -Property Name
|
||||
Disconnect-From -RemoteHost "vcr01.myside.local" -Type VMware
|
||||
### EXAMPLE 7
|
||||
```
|
||||
Connect-To -RemoteHost "exchange01.myside.local" -Type ExchangeHTTPS
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -RemoteHost
|
||||
Specify the host, for which you would like to change the credentials.
|
||||
### -Credentials
|
||||
Use this parameter to bypass the stored credentials.
|
||||
Without this parameter Connect-To tries to read the
|
||||
needed credentials from the CredentialStore.
|
||||
If you provide this parameter you skip this lookup behavior.
|
||||
So you can use it to enable credentials without preparing any user interaction.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Type: PSCredential
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
@ -88,47 +93,7 @@ same hostname.
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Type
|
||||
Specify the host type of the target.
|
||||
Currently implemented targets are:
|
||||
- CiscoUcs Establish a connection to a Cisco UCS fabric interconnect.
|
||||
- FTP Establish a connection to a FTP host.
|
||||
- NetAppFAS Establish a connection to a NetApp Clustered ONTAP filer.
|
||||
- VMware Establish a connection to a VMware vCenter or ESXi host.
|
||||
- CisServer Establish a connection to a Vmware CisServer.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Credentials
|
||||
Use this parameter to bypass the stored credentials.
|
||||
Without this parameter Connect-To tries to read the
|
||||
needed credentials from the CredentialStore.
|
||||
If you provide this parameter you skip this lookup behavior.
|
||||
So you can use it to enable credentials without preparing any user interaction.
|
||||
|
||||
```yaml
|
||||
Type: PSCredential
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -143,7 +108,7 @@ Define a custom path to a shared CredentialStore.
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -152,6 +117,21 @@ Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -RemoteHost
|
||||
Specify the host, for which you would like to change the credentials.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Shared
|
||||
Switch to shared mode with this param.
|
||||
This enforces the command to work with a shared CredentialStore which
|
||||
@ -160,7 +140,7 @@ can be decrypted across systems.
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -169,8 +149,26 @@ Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Type
|
||||
Specify the host type of the target.
|
||||
Currently implemented targets are: Possible connection values are:
|
||||
CiscoUcs, FTP, NetAppFAS, VMware, CisServer, ExchangeHTTP, ExchangeHTTPS, SCP.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### CommonParameters
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
|
||||
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
|
||||
## INPUTS
|
||||
|
||||
@ -181,11 +179,9 @@ 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
|
||||
|
||||
|
@ -21,45 +21,70 @@ Terminates a session established with Connect-To using a CredentialStoreItem.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
### EXAMPLE 1
|
||||
```
|
||||
Disconnect-From -RemoteHost "ucs.myside.local" -Type CiscoUcs
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 2 --------------------------
|
||||
### EXAMPLE 2
|
||||
```
|
||||
Disconnect-From -RemoteHost "ftp.myside.local" -Type FTP
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 3 --------------------------
|
||||
### EXAMPLE 3
|
||||
```
|
||||
Disconnect-From -RemoteHost "fas.myside.local" -Type NetAppFAS
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 4 --------------------------
|
||||
### EXAMPLE 4
|
||||
```
|
||||
Disconnect-From -RemoteHost "esx01.myside.local" -Type VMware
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 5 --------------------------
|
||||
### EXAMPLE 5
|
||||
```
|
||||
Disconnect-From -RemoteHost "esx01.myside.local" -Type VMware -Force:$True
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 6 --------------------------
|
||||
### EXAMPLE 6
|
||||
```
|
||||
Disconnect-From -RemoteHost "vcenter.myside.local" -Type CisServer
|
||||
```
|
||||
|
||||
### EXAMPLE 7
|
||||
```
|
||||
Disconnect-From -RemoteHost "exchange01.myside.local" -Type ExchangeHTTP
|
||||
```
|
||||
|
||||
### EXAMPLE 8
|
||||
```
|
||||
Disconnect-From -RemoteHost "exchange01.myside.local" -Type ExchangeHTTPS
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -Force
|
||||
Force the disconnect, even if the disconnect would fail.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: False
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -RemoteHost
|
||||
Specify the remote endpoint, whose session you would like to terminate.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
@ -70,17 +95,13 @@ Accept wildcard characters: False
|
||||
|
||||
### -Type
|
||||
Specify the host type of the target.
|
||||
Currently implemented targets are:
|
||||
- CiscoUcs Terminates the connection from a Cisco UCS Fabric Interconnect.
|
||||
- FTP Terminates the connection from a FTP host.
|
||||
- NetAppFAS Terminates the connection from a NetApp Clustered ONTAP filer.
|
||||
- VMware Terminates the connection from a VMware vCenter or ESXi host.
|
||||
- CisServer Terminates the connection from a Vmware CisServer.
|
||||
Currently implemented targets are: CiscoUcs, FTP, NetAppFAS, VMware,
|
||||
CisServer, ExchangeHTTP, ExchangeHTTPS, SCP.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
@ -89,23 +110,9 @@ Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Force
|
||||
Force the disconnect, even if the disconnect would fail.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: False
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### CommonParameters
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
|
||||
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
|
||||
## INPUTS
|
||||
|
||||
@ -116,11 +123,9 @@ 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
|
||||
|
||||
|
@ -31,7 +31,7 @@ Get-CredentialStoreItem.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
### EXAMPLE 1
|
||||
```
|
||||
$CSContent = Get-CredentialStore -Path "C:\TMP\mystore.json"
|
||||
```
|
||||
@ -44,7 +44,7 @@ Define a custom path to a shared CredentialStore.
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -61,7 +61,7 @@ can be decrypted across systems.
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -71,7 +71,8 @@ Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### CommonParameters
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
|
||||
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
|
||||
## INPUTS
|
||||
|
||||
|
@ -28,20 +28,38 @@ Return the credential as PSCredential object.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
### EXAMPLE 1
|
||||
```
|
||||
$myCreds = Get-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -Identifier
|
||||
Provide a custom identifier to the given remote host key.
|
||||
This enables you to store multiple credentials
|
||||
for a single remote host entry.
|
||||
For example ad/sys1, ftp/sys1, mssql/sys1
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Path
|
||||
Define a custom path to a shared CredentialStore.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -56,7 +74,7 @@ Specify the host, for which you would like to change the credentials.
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: Named
|
||||
@ -65,24 +83,6 @@ Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Identifier
|
||||
Provide a custom identifier to the given remote host key.
|
||||
This enables you to store multiple credentials
|
||||
for a single remote host entry.
|
||||
For example ad/sys1, ftp/sys1, mssql/sys1
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Shared
|
||||
Switch to shared mode with this param.
|
||||
This enforces the command to work with a shared CredentialStore which
|
||||
@ -91,7 +91,7 @@ can be decrypted across systems.
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -101,7 +101,8 @@ Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### CommonParameters
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
|
||||
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
|
||||
## INPUTS
|
||||
|
||||
|
@ -5,43 +5,84 @@ online version: https://github.com/OCram85/PSCredentialStore
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Get-CredentialStoreItem
|
||||
# New-CredentialStore
|
||||
|
||||
## SYNOPSIS
|
||||
Returns the Credential from a given remote host item.
|
||||
Creates a new credential store File
|
||||
|
||||
## SYNTAX
|
||||
|
||||
### Private (Default)
|
||||
```
|
||||
Get-CredentialStoreItem -RemoteHost <String> [-Identifier <String>] [<CommonParameters>]
|
||||
New-CredentialStore [-Force] [<CommonParameters>]
|
||||
```
|
||||
|
||||
### Shared
|
||||
```
|
||||
Get-CredentialStoreItem [-Path <String>] -RemoteHost <String> [-Identifier <String>] [-Shared]
|
||||
[<CommonParameters>]
|
||||
New-CredentialStore [-Shared] [-Path <String>] [-Force] [<CommonParameters>]
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
Return the credential as PSCredential object.
|
||||
You need to run this script first to create a new credential store before you try to
|
||||
save new credentials with New-CredentialStoreItem.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
### EXAMPLE 1
|
||||
```
|
||||
$myCreds = Get-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||
New-CredentialStore
|
||||
```
|
||||
|
||||
# Creates a new private CredentialStore
|
||||
|
||||
### EXAMPLE 2
|
||||
```
|
||||
New-CredentialStore -Force
|
||||
```
|
||||
|
||||
# Resets an existing private CredentialStore
|
||||
|
||||
### EXAMPLE 3
|
||||
```
|
||||
New-CredentialStore -Shared
|
||||
```
|
||||
|
||||
# Creates a new shared CredentialStore
|
||||
|
||||
### EXAMPLE 4
|
||||
```
|
||||
New-CredentialStore -Shared -Path "C:\TMP\CredentialStore.json"
|
||||
```
|
||||
|
||||
# Creates a new shared CredentialStore in the given location.
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -Force
|
||||
Use this switch to reset an existing store.
|
||||
The complete content will be wiped.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: False
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Path
|
||||
Define a custom path to a shared CredentialStore.
|
||||
Define a location for the new shared CredentialStore.
|
||||
The default store will be created in
|
||||
$Env:ProgramData\PSCredentialStore dir.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -50,48 +91,16 @@ Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -RemoteHost
|
||||
Specify the host, for which you would like to change the credentials.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Identifier
|
||||
Provide a custom identifier to the given remote host key.
|
||||
This enables you to store multiple credentials
|
||||
for a single remote host entry.
|
||||
For example ad/sys1, ftp/sys1, mssql/sys1
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Shared
|
||||
Switch to shared mode with this param.
|
||||
This enforces the command to work with a shared CredentialStore which
|
||||
can be decrypted across systems.
|
||||
Creates a CredentialStore in the Shared mode.
|
||||
This enables you to read the CredentialStore Items on
|
||||
different systems or profiles.
|
||||
In addition you can optionally provide a custom path wit the -Path parameter.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -101,7 +110,8 @@ Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### CommonParameters
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
|
||||
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
|
||||
## INPUTS
|
||||
|
||||
@ -109,11 +119,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
### [System.Management.Automation.PSCredential]
|
||||
### [None]
|
||||
|
||||
## NOTES
|
||||
\`\`\`
|
||||
File Name : Get-CredentialStoreItem.ps1
|
||||
File Name : New-CredentialStore.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
\`\`\`
|
||||
|
@ -33,38 +33,23 @@ a VIConnection, NetApp FAS or UCS Fabric Interconnect.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
### EXAMPLE 1
|
||||
```
|
||||
New-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -Path
|
||||
Define the store in which you would like to add a new item.
|
||||
### -Credential
|
||||
You can provide credentials optionally as pre existing pscredential object.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Type: PSCredential
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -RemoteHost
|
||||
The identifier or rather name for the given credentials.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
@ -79,7 +64,7 @@ For example ad/sys1, ftp/sys1, mssql/sys1
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -88,16 +73,31 @@ Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Credential
|
||||
You can provide credentials optionally as pre existing pscredential object.
|
||||
### -Path
|
||||
Define the store in which you would like to add a new item.
|
||||
|
||||
```yaml
|
||||
Type: PSCredential
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
Type: String
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -RemoteHost
|
||||
The identifier or rather name for the given credentials.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
@ -109,7 +109,7 @@ Accept wildcard characters: False
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -119,7 +119,8 @@ Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### CommonParameters
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
|
||||
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
|
||||
## INPUTS
|
||||
|
||||
|
@ -8,36 +8,39 @@ Locale: en-US
|
||||
|
||||
# PSCredentialStore Module
|
||||
## Description
|
||||
PSCredentialStore enables managing multiple PSCredential objects.
|
||||
{{Manually Enter Description Here}}
|
||||
|
||||
## PSCredentialStore Cmdlets
|
||||
### [Connect-To](Connect-To.md)
|
||||
Connects to the given host using the stored CredentialStoreItem.
|
||||
{{Manually Enter Connect-To Description Here}}
|
||||
|
||||
### [Disconnect-From](Disconnect-From.md)
|
||||
Terminates a session established with Connect-To using a CredentialStoreItem.
|
||||
{{Manually Enter Disconnect-From Description Here}}
|
||||
|
||||
### [Get-CredentialStore](Get-CredentialStore.md)
|
||||
Reads the complete content of the credential store and returns it as a new object.
|
||||
{{Manually Enter Get-CredentialStore Description Here}}
|
||||
|
||||
### [Get-CredentialStoreItem](Get-CredentialStoreItem.md)
|
||||
Returns the Credential from a given remote host item.
|
||||
{{Manually Enter Get-CredentialStoreItem Description Here}}
|
||||
|
||||
### [Get-CredentialStoreItem](Get-CredentialStoreItem.md)
|
||||
Returns the Credential from a given remote host item.
|
||||
### [New-CredentialStore](New-CredentialStore.md)
|
||||
{{Manually Enter New-CredentialStore Description Here}}
|
||||
|
||||
### [New-CredentialStoreItem](New-CredentialStoreItem.md)
|
||||
Adds a credential store item containing host, user and password to the given store.
|
||||
{{Manually Enter New-CredentialStoreItem Description Here}}
|
||||
|
||||
### [Remove-CredentialStoreItem](Remove-CredentialStoreItem.md)
|
||||
Remove the given credentials from the credential store.
|
||||
{{Manually Enter Remove-CredentialStoreItem Description Here}}
|
||||
|
||||
### [Set-CredentialStoreItem](Set-CredentialStoreItem.md)
|
||||
Changes the credentials for the given remote host in the store.
|
||||
{{Manually Enter Set-CredentialStoreItem Description Here}}
|
||||
|
||||
### [Test-CredentialStore](Test-CredentialStore.md)
|
||||
Returns the credential store state.
|
||||
{{Manually Enter Test-CredentialStore Description Here}}
|
||||
|
||||
### [Test-CredentialStoreItem](Test-CredentialStoreItem.md)
|
||||
Checks if the given RemoteHost identifier combination exists in the credential store.
|
||||
{{Manually Enter Test-CredentialStoreItem Description Here}}
|
||||
|
||||
### [Test-CSConnection](Test-CSConnection.md)
|
||||
{{Manually Enter Test-CSConnection Description Here}}
|
||||
|
||||
|
@ -28,7 +28,7 @@ Use this CMDLet to completely remove an credential store item.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
### EXAMPLE 1
|
||||
```
|
||||
Remove-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||
```
|
||||
@ -37,13 +37,30 @@ Remove-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -Identifier
|
||||
Defaults to "".
|
||||
Specify a string, which separates two CredentialStoreItems for the
|
||||
same hostname.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Path
|
||||
Define the store in which your given host entry already exists.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -58,7 +75,7 @@ Specify the host you for which you would like to change the credentials.
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: Named
|
||||
@ -67,23 +84,6 @@ Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Identifier
|
||||
Defaults to "".
|
||||
Specify a string, which separates two CredentialStoreItems for the
|
||||
same hostname.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Shared
|
||||
Switch to shared mode with this param.
|
||||
This enforces the command to work with a shared CredentialStore which
|
||||
@ -92,7 +92,7 @@ can be decrypted across systems.
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -102,7 +102,8 @@ Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### CommonParameters
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
|
||||
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
|
||||
## INPUTS
|
||||
|
||||
|
@ -28,7 +28,7 @@ Set-CredentialStoreItem [-Path <String>] -RemoteHost <String> [-Identifier <Stri
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
### EXAMPLE 1
|
||||
```
|
||||
Set-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||
```
|
||||
@ -37,13 +37,30 @@ Set-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.lo
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -Identifier
|
||||
Defaults to "".
|
||||
Specify a string, which separates two CredentialStoreItems for the
|
||||
same hostname.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Path
|
||||
Define the store in which your given host entry already exists.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -58,7 +75,7 @@ Specify the host you for which you would like to change the credentials.
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: Named
|
||||
@ -67,23 +84,6 @@ Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Identifier
|
||||
Defaults to "".
|
||||
Specify a string, which separates two CredentialStoreItems for the
|
||||
same hostname.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Shared
|
||||
Switch to shared mode with this param.
|
||||
This enforces the command to work with a shared CredentialStore which
|
||||
@ -92,7 +92,7 @@ can be decrypted across systems.
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -102,7 +102,8 @@ Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### CommonParameters
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
|
||||
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
|
||||
## INPUTS
|
||||
|
||||
|
83
docs/Test-CSConnection.md
Normal file
83
docs/Test-CSConnection.md
Normal file
@ -0,0 +1,83 @@
|
||||
---
|
||||
external help file: PSCredentialStore-help.xml
|
||||
Module Name: PSCredentialStore
|
||||
online version: https://github.com/OCram85/PSCredentialStore
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Test-CSConnection
|
||||
|
||||
## SYNOPSIS
|
||||
Returns the connection state of a given type to the remote host.
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
Test-CSConnection [-RemoteHost] <String> [-Type] <String> [<CommonParameters>]
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
Use this script to check a connection which was established with the \`Connect-To\` cmdlet.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### EXAMPLE 1
|
||||
```
|
||||
.\Test-CMConnection -RemoteHost "r0-i01-vcr01.p0r.kivbf-cloud.net" -Type VMware
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -RemoteHost
|
||||
Define the remote host you would like to check.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Type
|
||||
Define the connection type you would like to check.
|
||||
See the \`Connect-To\` documentation
|
||||
for valid type values.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### CommonParameters
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
|
||||
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
|
||||
## INPUTS
|
||||
|
||||
### [None]
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
### [Boolean]
|
||||
|
||||
## 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)
|
||||
|
@ -30,7 +30,7 @@ the file exists.
|
||||
## EXAMPLES
|
||||
|
||||
### Example 1
|
||||
```
|
||||
```powershell
|
||||
PS C:\> {{ Add example code here }}
|
||||
```
|
||||
|
||||
@ -44,7 +44,7 @@ Define a custom path to a shared CredentialStore.
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -61,7 +61,7 @@ can be decrypted across systems.
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -71,7 +71,8 @@ Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### CommonParameters
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
|
||||
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
|
||||
## INPUTS
|
||||
|
||||
|
@ -30,7 +30,7 @@ you try to interact with it.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
### EXAMPLE 1
|
||||
```
|
||||
If (Test-CredentialStoreItem -RemoteHost "Default") {
|
||||
```
|
||||
@ -43,6 +43,23 @@ Else {
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -Identifier
|
||||
Adds an optional identifier to the given RemoteHost.
|
||||
Makes it possible to store multiple credentials
|
||||
for a single host.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Path
|
||||
Define a custom credential store you try to read from.
|
||||
Without the \`-Path\` parameter
|
||||
@ -51,7 +68,7 @@ Without the \`-Path\` parameter
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -66,7 +83,7 @@ Specify the host, for which you would like to change the credentials.
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: Named
|
||||
@ -75,23 +92,6 @@ Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Identifier
|
||||
Adds an optional identifier to the given RemoteHost.
|
||||
Makes it possible to store multiple credentials
|
||||
for a single host.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Shared
|
||||
Switch to shared mode with this param.
|
||||
This enforces the command to work with a shared CredentialStore which
|
||||
@ -100,7 +100,7 @@ can be decrypted across systems.
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: Shared
|
||||
Aliases:
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
@ -110,7 +110,8 @@ Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### CommonParameters
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
|
||||
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
|
||||
|
||||
## INPUTS
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
theme: jekyll-theme-midnight
|
@ -72,7 +72,12 @@ If you have already installed the underlying framework your can connect to:
|
||||
* Required Modules: [`VMware.VimAutomation.Core`](https://www.powershellgallery.com/packages/VMware.PowerCLI)
|
||||
* **CisServer** - Establish a connection to the CisServer Service on vCenter Host.
|
||||
* Required Modules: [`VMware.VimAutomation.Cis.Core`](https://www.powershellgallery.com/packages/VMware.PowerCLI))
|
||||
|
||||
* **ExchangeHTTP** - Establish a remote connection with an Exchange endpoint via http.
|
||||
* Requires PowerShell remoting
|
||||
* **ExchangeHTTPS** - Establish a remote connection with an Exchange endpoint via https.
|
||||
* Requires PowerShell remoting
|
||||
* **SCP** - Establish a SCP connection.
|
||||
* Required Modules: [`WinSCP`](https://www.powershellgallery.com/packages/WinSCP)
|
||||
# EXAMPLES
|
||||
|
||||
```powershell
|
||||
|
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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -14,14 +14,8 @@ function Connect-To {
|
||||
same hostname.
|
||||
|
||||
.PARAMETER Type
|
||||
Specify the host type of the target. Currently implemented targets are:
|
||||
- CiscoUcs Establish a connection to a Cisco UCS fabric interconnect.
|
||||
- FTP Establish a connection to a FTP host.
|
||||
- NetAppFAS Establish a connection to a NetApp Clustered ONTAP filer.
|
||||
- VMware Establish a connection to a VMware vCenter or ESXi host.
|
||||
- CisServer Establish a connection to a Vmware CisServer.
|
||||
- ExchangeHTTP Start a new remote session to the given Exchange server via unsecure http.
|
||||
- Exchange HTTPS Start a new remote session to the given exchange server with the secure https endpoint.
|
||||
Specify the host type of the target. Currently implemented targets are: Possible connection values are:
|
||||
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
|
||||
@ -62,12 +56,6 @@ function Connect-To {
|
||||
.EXAMPLE
|
||||
Connect-To -RemoteHost "exchange01.myside.local" -Type ExchangeHTTPS
|
||||
|
||||
.EXAMPLE
|
||||
$MyCreds = Get-Credential
|
||||
Connect-To -RemoteHost "vcr01.myside.local" -Type VMware -Credentials $MyCreds
|
||||
Get-VM -Name "*vlm*" | Select-Object -Property Name
|
||||
Disconnect-From -RemoteHost "vcr01.myside.local" -Type VMware
|
||||
|
||||
.NOTES
|
||||
File Name : Connect-To.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
@ -89,7 +77,16 @@ function Connect-To {
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
||||
[ValidateSet('CiscoUcs', 'FTP', 'NetAppFAS', 'VMware', 'CisServer', 'ExchangeHTTP', 'ExchangeHTTPS')]
|
||||
[ValidateSet(
|
||||
'CiscoUcs',
|
||||
'FTP',
|
||||
'NetAppFAS',
|
||||
'VMware',
|
||||
'CisServer',
|
||||
'ExchangeHTTP',
|
||||
'ExchangeHTTPS',
|
||||
'SCP'
|
||||
)]
|
||||
[string]$Type,
|
||||
|
||||
[Parameter(Mandatory = $False, ParameterSetName = "Shared")]
|
||||
@ -251,7 +248,6 @@ function Connect-To {
|
||||
ErrorAction = 'Stop'
|
||||
}
|
||||
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
|
||||
$Global:PSExchangeRemote
|
||||
}
|
||||
catch {
|
||||
# Write a error message to the log.
|
||||
@ -271,7 +267,6 @@ function Connect-To {
|
||||
ErrorAction = 'Stop'
|
||||
}
|
||||
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
|
||||
$Global:PSExchangeRemote
|
||||
}
|
||||
catch {
|
||||
# Write a error message to the log.
|
||||
@ -282,6 +277,36 @@ function Connect-To {
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
"SCP" {
|
||||
$WinSCPSessionParams = @{
|
||||
Credential = $creds
|
||||
Hostname = $RemoteHost
|
||||
Protocol = 'Scp'
|
||||
GiveUpSecurityAndAcceptAnySshHostKey = $True
|
||||
}
|
||||
try {
|
||||
$SessionOption = New-WinSCPSessionOption @WinSCPSessionParams
|
||||
$Global:WinSCPSession = New-WinSCPSession -SessionOption $SessionOption
|
||||
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"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
# Check the Connection State
|
||||
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. But now it seems to be lost!" -f $RemoteHost, $Type
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
default {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
|
@ -14,14 +14,9 @@ function Disconnect-From {
|
||||
same hostname.
|
||||
|
||||
.PARAMETER Type
|
||||
Specify the host type of the target. Currently implemented targets are:
|
||||
- CiscoUcs Terminates the connection from a Cisco UCS Fabric Interconnect.
|
||||
- FTP Terminates the connection from a FTP host.
|
||||
- NetAppFAS Terminates the connection from a NetApp Clustered ONTAP filer.
|
||||
- VMware Terminates the connection from a VMware vCenter or ESXi host.
|
||||
- CisServer Terminates the connection from a Vmware CisServer.
|
||||
- ExchangeHTTP Remove the existing remote session to the given Exchange server
|
||||
- ExchangeHTTPS Remove the existing remote session to the given Exchange server
|
||||
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.
|
||||
|
||||
@ -70,7 +65,16 @@ function Disconnect-From {
|
||||
[string]$RemoteHost,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateSet('CiscoUcs', 'FTP', 'NetAppFAS', 'VMware', 'CisServer', 'ExchangeHTTP', 'ExchangeHTTPS')]
|
||||
[ValidateSet(
|
||||
'CiscoUcs',
|
||||
'FTP',
|
||||
'NetAppFAS',
|
||||
'VMware',
|
||||
'CisServer',
|
||||
'ExchangeHTTP',
|
||||
'ExchangeHTTPS',
|
||||
'SCP'
|
||||
)]
|
||||
[string]$Type,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
@ -178,6 +182,18 @@ function Disconnect-From {
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
"SCP" {
|
||||
if ($Global:WinSCPSession.Opened) {
|
||||
Remove-WinSCPSession -WinSCPSession $Global:WinSCPSession
|
||||
}
|
||||
else {
|
||||
$MessageParams = @{
|
||||
Message = "There is no open WinSCP Session"
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
default {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
|
@ -32,6 +32,12 @@
|
||||
"Modules": [
|
||||
"VMware.VimAutomation.Cis.Core"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "SCP",
|
||||
"Modules": [
|
||||
"WinSCP"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
29
src/Helper/Get-ModuleBase.ps1
Normal file
29
src/Helper/Get-ModuleBase.ps1
Normal file
@ -0,0 +1,29 @@
|
||||
function Get-ModuleBase {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Returns the base path of the current module.
|
||||
|
||||
.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()]
|
||||
param()
|
||||
begin {}
|
||||
process {
|
||||
return $MyInvocation.MyCommand.Module.ModuleBase
|
||||
}
|
||||
end {}
|
||||
}
|
@ -32,6 +32,7 @@ function Get-RandomKey {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[ValidateSet(16, 24, 32)]
|
||||
[string]$size
|
||||
)
|
||||
|
@ -53,11 +53,12 @@ function Resolve-Dependency {
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Name
|
||||
)
|
||||
|
||||
begin {
|
||||
$ModuleRootDir = $MyInvocation.MyCommand.Module.ModuleBase
|
||||
$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
|
||||
@ -65,16 +66,16 @@ function Resolve-Dependency {
|
||||
else {
|
||||
Write-Warning ("Could not find the dependency file: {0}" -f $DepFilePath)
|
||||
}
|
||||
$res = @()
|
||||
}
|
||||
|
||||
process {
|
||||
$SelectedDependency = $Dependency.Optional | Where-Object {$_.Name -match $Name}
|
||||
|
||||
$res = @()
|
||||
foreach ($Module in $SelectedDependency.Modules) {
|
||||
$res += Test-Module -Name $Module
|
||||
}
|
||||
if ($res -contains $false) {
|
||||
# return false if there was not module at all
|
||||
if (($res -contains $false) -or ($res.Count -eq 0)) {
|
||||
return $false
|
||||
}
|
||||
else {
|
||||
|
@ -83,14 +83,14 @@ Could not find the required {0} called {1}. Please install the required {0} to r
|
||||
}
|
||||
|
||||
'PSSnapin' {
|
||||
if (Get-PSSnapin -Name $Name -Registered) {
|
||||
if (Get-PSSnapin -Name $Name -Registered -ErrorAction SilentlyContinue) {
|
||||
return $true
|
||||
}
|
||||
else {
|
||||
if ($StopIfFails) {
|
||||
Write-Error -Message $Message -ErrorAction Stop -Category NotInstalled
|
||||
return $false
|
||||
}
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
|
15
tests/00_BasicModule.Tests.ps1
Normal file
15
tests/00_BasicModule.Tests.ps1
Normal file
@ -0,0 +1,15 @@
|
||||
$RepoRoot = (Get-GitDirectory).replace('\.git', '')
|
||||
|
||||
Describe "Pre-Flight module tests" {
|
||||
$ManifestFilePath = "{0}\src\PSCredentialstore.psd1" -f $RepoRoot
|
||||
Context "Manifest file related" {
|
||||
It "Test the parsed file itsef" {
|
||||
{ Test-ModuleManifest -Path $ManifestFilePath } | Should -Not -Throw
|
||||
}
|
||||
}
|
||||
Context "Module consistency tests" {
|
||||
IT "Importing should work" {
|
||||
{ Import-Module -Name $ManifestFilePath -Global -Force }| Should -Not -Throw
|
||||
}
|
||||
}
|
||||
}
|
60
tests/ChallengeFile/01_Set-ChallengeFile.Tests.ps1
Normal file
60
tests/ChallengeFile/01_Set-ChallengeFile.Tests.ps1
Normal file
@ -0,0 +1,60 @@
|
||||
#region HEADER
|
||||
$RepoRoot = (Get-GitDirectory).replace('\.git', '')
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
|
||||
$sut = $sut -replace "\d{2}`_", ''
|
||||
$suthome = (Get-ChildItem -Path $RepoRoot -Exclude ".\tests\" -Filter $sut -Recurse).FullName
|
||||
# Skip try loading the source file if it doesn't exists.
|
||||
If ($suthome.Length -gt 0) {
|
||||
. $suthome
|
||||
}
|
||||
Else {
|
||||
Write-Warning ("Could not find source file {0}" -f $sut)
|
||||
}
|
||||
|
||||
# load additional functions defined in the repository. Replace the expression <FunctionName>.
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Get-RandomKey.ps1" -Recurse).FullName
|
||||
|
||||
#endregion HEADER
|
||||
|
||||
Describe "Set-ChallengeFile" {
|
||||
Context "Tests with custom path" {
|
||||
It "Working dir and path not exist" {
|
||||
{Set-ChallengeFile -Path 'C:\PSCredentialStore\Challenge.bin'} | Should -Not -Throw
|
||||
}
|
||||
It "No parameter and non file should return true" {
|
||||
if (Test-Path -Path ("{0}\PSCredentialStore\Challenge.bin" -f $env:ProgramData)) {
|
||||
Remove-Item -Path ("{0}\PSCredentialStore\Challenge.bin" -f $env:ProgramData)
|
||||
}
|
||||
Set-ChallengeFile
|
||||
Test-Path -Path ("{0}\PSCredentialStore\Challenge.bin" -f $env:ProgramData) | Should -Be $true
|
||||
}
|
||||
It "Existing Credential file should return error" {
|
||||
{ Set-ChallengeFile } | Should -Throw
|
||||
Remove-Item -Path ("{0}\PSCredentialStore\Challenge.bin" -f $env:ProgramData)
|
||||
}
|
||||
It "Use -Force switch should create a new challenge file" {
|
||||
# prepare for test and clean up old data
|
||||
if (Test-Path -Path ("{0}\PSCredentialStore\Challenge.bin" -f $env:ProgramData)) {
|
||||
Remove-Item -Path ("{0}\PSCredentialStore\Challenge.bin" -f $env:ProgramData)
|
||||
}
|
||||
Set-ChallengeFile
|
||||
{ Set-ChallengeFile -Force } | Should -Not -Throw
|
||||
}
|
||||
It "Test directory creation for shared store" {
|
||||
if (Test-Path -Path ("{0}\PSCredentialStore" -f $env:ProgramData)) {
|
||||
Remove-Item -Path ("{0}\PSCredentialStore" -f $env:ProgramData) -Force -Recurse
|
||||
}
|
||||
Set-ChallengeFile
|
||||
Test-Path -Path ("{0}\PSCredentialStore" -f $env:ProgramData) | Should -Be $true
|
||||
}
|
||||
}
|
||||
Context "General Exception handling" {
|
||||
Mock New-Item {throw "foobar exception"}
|
||||
It "Test exception handling if the root directory could not be created" {
|
||||
if (Test-Path -Path ("{0}\PSCredentialStore" -f $env:ProgramData)) {
|
||||
Remove-Item -Path ("{0}\PSCredentialStore" -f $env:ProgramData) -Force -Recurse
|
||||
}
|
||||
{ Set-ChallengeFile } | Should -Throw "Could not create the parent data dir"
|
||||
}
|
||||
}
|
||||
}
|
38
tests/ChallengeFile/01_Test-ChallengeFile.Tests.ps1
Normal file
38
tests/ChallengeFile/01_Test-ChallengeFile.Tests.ps1
Normal file
@ -0,0 +1,38 @@
|
||||
#region HEADER
|
||||
$RepoRoot = (Get-GitDirectory).replace('\.git', '')
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
|
||||
$sut = $sut -replace "\d{2}`_", ''
|
||||
$suthome = (Get-ChildItem -Path $RepoRoot -Exclude ".\tests\" -Filter $sut -Recurse).FullName
|
||||
# Skip try loading the source file if it doesn't exists.
|
||||
If ($suthome.Length -gt 0) {
|
||||
. $suthome
|
||||
}
|
||||
Else {
|
||||
Write-Warning ("Could not find source file {0}" -f $sut)
|
||||
}
|
||||
|
||||
# load additional functions defined in the repository. Replace the expression <FunctionName>.
|
||||
#. (Get-ChildItem -Path $RepoRoot -Filter "Test-ChallengeFile.ps1" -Recurse).FullName
|
||||
|
||||
#endregion HEADER
|
||||
|
||||
Describe "Test-ChallengeFile" {
|
||||
Context "Basic input tests" {
|
||||
Mock Test-Path {return $true}
|
||||
It "No parameter with existing challenge file" {
|
||||
{Test-ChallengeFile} | Should -Not -Throw
|
||||
}
|
||||
It "No parameter and existing file should return true" {
|
||||
Test-ChallengeFile | Should -Be $true
|
||||
}
|
||||
}
|
||||
Context "Execute with parameter" {
|
||||
$TestChFile = "{0}\resources\cs\Challenge.bin" -f $RepoRoot
|
||||
It "Provide valid path" {
|
||||
Test-ChallengeFile -Path $TestChFile | Should -Be $true
|
||||
}
|
||||
It "Provide fake path" {
|
||||
Test-ChallengeFile -Path "C:\notexisting.bin" | Should -Be $false
|
||||
}
|
||||
}
|
||||
}
|
25
tests/Helper/01_Get-ModuleBase.Tests.ps1
Normal file
25
tests/Helper/01_Get-ModuleBase.Tests.ps1
Normal file
@ -0,0 +1,25 @@
|
||||
#region HEADER
|
||||
$RepoRoot = (Get-GitDirectory).replace('\.git', '')
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
|
||||
$sut = $sut -replace "\d{2}`_", ''
|
||||
$suthome = (Get-ChildItem -Path $RepoRoot -Exclude ".\tests\" -Filter $sut -Recurse).FullName
|
||||
# Skip try loading the source file if it doesn't exists.
|
||||
If ($suthome.Length -gt 0) {
|
||||
. $suthome
|
||||
}
|
||||
Else {
|
||||
Write-Warning ("Could not find source file {0}" -f $sut)
|
||||
}
|
||||
|
||||
# load additional functions defined in the repository. Replace the expression <FunctionName>.
|
||||
# . (Get-ChildItem -Path $RepoRoot -Filter "<FunctionName>.ps1" -Recurse).FullName
|
||||
|
||||
#endregion HEADER
|
||||
|
||||
Describe "Get-ModuleBase" {
|
||||
Context "Basic syntax check" {
|
||||
It "Test1: Should not throw" {
|
||||
{ Get-ModuleBase } | Should -Not -Throw
|
||||
}
|
||||
}
|
||||
}
|
39
tests/Helper/01_Get-RandomKey.Tests.ps1
Normal file
39
tests/Helper/01_Get-RandomKey.Tests.ps1
Normal file
@ -0,0 +1,39 @@
|
||||
#region HEADER
|
||||
$RepoRoot = (Get-GitDirectory).replace('\.git', '')
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
|
||||
$sut = $sut -replace "\d{2}`_", ''
|
||||
$suthome = (Get-ChildItem -Path $RepoRoot -Exclude ".\tests\" -Filter $sut -Recurse).FullName
|
||||
# Skip try loading the source file if it doesn't exists.
|
||||
If ($suthome.Length -gt 0) {
|
||||
. $suthome
|
||||
}
|
||||
Else {
|
||||
Write-Warning ("Could not find source file {0}" -f $sut)
|
||||
}
|
||||
|
||||
# load additional functions defined in the repository. Replace the expression <FunctionName>.
|
||||
# . (Get-ChildItem -Path $RepoRoot -Filter "<FunctionName>.ps1" -Recurse).FullName
|
||||
|
||||
#endregion HEADER
|
||||
|
||||
Describe "Get-RandomKey" {
|
||||
Context "Basic input tests" {
|
||||
It "Test1: Should throw if wrong size is given" {
|
||||
{Get-RandomKey -size 43} | Should -Throw
|
||||
}
|
||||
}
|
||||
Context "Basic syntax check" {
|
||||
It "Test1: Should return a key with a length of 16" {
|
||||
$Key = Get-RandomKey -size 16
|
||||
$Key.length | Should -Be 16
|
||||
}
|
||||
It "Test2: Should return a key with a length of 24" {
|
||||
$Key = Get-RandomKey -size 24
|
||||
$Key.length | Should -Be 24
|
||||
}
|
||||
It "Test3: Should return a key with a length of 32" {
|
||||
$Key = Get-RandomKey -size 32
|
||||
$Key.length | Should -Be 32
|
||||
}
|
||||
}
|
||||
}
|
53
tests/Helper/01_Resolve-Dependency.Tests.ps1
Normal file
53
tests/Helper/01_Resolve-Dependency.Tests.ps1
Normal file
@ -0,0 +1,53 @@
|
||||
#region HEADER
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
# $RepoRoot = (Get-Item -Path $here).Parent.Parent.FullName
|
||||
$RepoRoot = (Get-GitDirectory).replace('\.git', '')
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
|
||||
$sut = $sut -replace "\d{2}`_", ''
|
||||
$suthome = (Get-ChildItem -Path $RepoRoot -Exclude ".\tests\" -Filter $sut -Recurse).FullName
|
||||
# Skip try loading the source file if it doesn't exists.
|
||||
If ($suthome.Length -gt 0) {
|
||||
. $suthome
|
||||
}
|
||||
Else {
|
||||
Write-Warning ("Could not find source file {0}" -f $sut)
|
||||
}
|
||||
|
||||
# load additional functions defined in the repository. Replace the expression <FunctionName>.
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Get-ModuleBase.ps1" -Recurse).FullName
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Test-Module.ps1" -Recurse).FullName
|
||||
|
||||
#endregion HEADER
|
||||
|
||||
Describe "Resolve-Dependency" {
|
||||
Context "Basic syntax check" {
|
||||
Mock Get-ModuleBase {return "{0}\resources" -f $PWD}
|
||||
Mock Test-Module {return $true}
|
||||
It "Test1: Should not throw" {
|
||||
{ Resolve-Dependency -Name 'foobar2000' } | Should -Not -Throw
|
||||
}
|
||||
It "Test2: Output type should be bool" {
|
||||
Resolve-Dependency -Name 'foobar2000' | Should -BeOfType bool
|
||||
}
|
||||
}
|
||||
Context "Enforce Error" {
|
||||
# Return incorrect module base to enforce there is no config file.
|
||||
Mock Get-ModuleBase {return "C:\"}
|
||||
It "Missing dependency file should not cause an error" {
|
||||
{ Resolve-Dependency -Name 'awesome'} | Should -Not -Throw
|
||||
}
|
||||
|
||||
It "Missing dependency file should return false" {
|
||||
Resolve-Dependency -Name 'awesome' | Should -Be $false
|
||||
}
|
||||
}
|
||||
Context "Testing input variations" {
|
||||
Mock Get-ModuleBase {return "{0}\resources" -f $PWD}
|
||||
It "Should return true if all given dependencies exist" {
|
||||
Resolve-Dependency -Name 'Existing' | Should -Be $true
|
||||
}
|
||||
It "Mixed results should return false" {
|
||||
Resolve-Dependency -Name 'PSGetMixed' | Should -Be $false
|
||||
}
|
||||
}
|
||||
}
|
65
tests/Helper/01_Test-Module.Tests.ps1
Normal file
65
tests/Helper/01_Test-Module.Tests.ps1
Normal file
@ -0,0 +1,65 @@
|
||||
#region HEADER
|
||||
$RepoRoot = (Get-GitDirectory).replace('\.git', '')
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
|
||||
$sut = $sut -replace "\d{2}`_", ''
|
||||
$suthome = (Get-ChildItem -Path $RepoRoot -Exclude ".\tests\" -Filter $sut -Recurse).FullName
|
||||
# Skip try loading the source file if it doesn't exists.
|
||||
If ($suthome.Length -gt 0) {
|
||||
. $suthome
|
||||
}
|
||||
Else {
|
||||
Write-Warning ("Could not find source file {0}" -f $sut)
|
||||
}
|
||||
|
||||
# load additional functions defined in the repository. Replace the expression <FunctionName>.
|
||||
#. (Get-ChildItem -Path $RepoRoot -Filter "<FunctionName>.ps1" -Recurse).FullName
|
||||
|
||||
#endregion HEADER
|
||||
|
||||
Describe "Test-ModuleName" {
|
||||
Context "Basic input tests" {
|
||||
It "Testing standard module should not throw" {
|
||||
{ Test-Module -Name 'PowerShellGet' -Type Module } | Should -Not -Throw
|
||||
}
|
||||
It "Existing module should return true" {
|
||||
Test-Module -Name 'PowerShellGet' -Type Module | Should -Be $true
|
||||
}
|
||||
}
|
||||
Context "Custom Type tests" {
|
||||
It "Using custom type should throw" {
|
||||
{ Test-Module -Name "foobarr" -Type Custom} | Should -Throw
|
||||
}
|
||||
}
|
||||
Context "Working with PSSnapins" {
|
||||
It "Loading first PSSnaping should not throw " {
|
||||
$Snap = Get-PSSnapin -Registered | Select-Object -First 1
|
||||
{ Test-Module -Name $Snap.Name -Type PSSnapin } | Should -Not -Throw
|
||||
}
|
||||
It "Loading first PSSnaping should return true" {
|
||||
$Snap = Get-PSSnapin -Registered | Select-Object -First 1
|
||||
Test-Module -Name $Snap.Name -Type PSSnapin | Should -Be $true
|
||||
}
|
||||
It "Not existing PSSnaping should return false" {
|
||||
Test-Module -Name 'foobar2000' -Type PSSnapin | Should -Be $false
|
||||
}
|
||||
It "StopifFails switch should thrown an error" {
|
||||
{Test-Module -Name 'foobar2000' -Type PSSnapin -StopIfFails }| Should -Throw
|
||||
}
|
||||
}
|
||||
Context "Working with modules" {
|
||||
It "Loading first module should not throw " {
|
||||
$Mod = Get-Module -ListAvailable | Select-Object -First 1
|
||||
{ Test-Module -Name $Mod.Name -Type Module } | Should -Not -Throw
|
||||
}
|
||||
It "Loading first module should return true" {
|
||||
$Snap = Get-Module -ListAvailable | Select-Object -First 1
|
||||
Test-Module -Name $Snap.Name -Type Module | Should -Be $true
|
||||
}
|
||||
It "Not existing module should return false" {
|
||||
Test-Module -Name 'foobar2000' -Type Module | Should -Be $false
|
||||
}
|
||||
It "StopifFails switch should thrown an error" {
|
||||
{Test-Module -Name 'foobar2000' -Type Module -StopIfFails }| Should -Throw
|
||||
}
|
||||
}
|
||||
}
|
@ -14,10 +14,10 @@ Else {
|
||||
}
|
||||
|
||||
# load additional functions defined in the repository. Replace the expression <FunctionName>.
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Test-CredentialStore.ps1" -Recurse).FullName
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "New-CredentialStore.ps1" -Recurse).FullName
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Get-CredentialStore.ps1" -Recurse).FullName
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Get-CredentialStoreItem.ps1" -Recurse).FullName
|
||||
#. (Get-ChildItem -Path $RepoRoot -Filter "Test-CredentialStore.ps1" -Recurse).FullName
|
||||
#. (Get-ChildItem -Path $RepoRoot -Filter "New-CredentialStore.ps1" -Recurse).FullName
|
||||
#. (Get-ChildItem -Path $RepoRoot -Filter "Get-CredentialStore.ps1" -Recurse).FullName
|
||||
#. (Get-ChildItem -Path $RepoRoot -Filter "Get-CredentialStoreItem.ps1" -Recurse).FullName
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Test-ChallengeFile.ps1" -Recurse).FullName
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Get-ChallengeFile.ps1" -Recurse).FullName
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Set-ChallengeFile.ps1" -Recurse).FullName
|
||||
@ -61,5 +61,42 @@ Describe "New-CredentialStoreItem" {
|
||||
$res = Get-Member -InputObject $tmpCS -Name $RemoteHost -Membertype Properties
|
||||
$res.Name | Should Be $RemoteHost
|
||||
}
|
||||
It "Adds Item with identifier to shared store" {
|
||||
$tmpCS = 'C:\CredentialStore.json'
|
||||
$UserName = "myuser"
|
||||
$Password = ConvertTo-SecureString -String "mypasswd" -AsPlainText -Force
|
||||
$mycreds = New-Object -TypeName PSCredential -ArgumentList $UserName, $Password
|
||||
$RemoteHost = "foobar2"
|
||||
New-CredentialStoreItem -Path $tmpCS -RemoteHost $RemoteHost -Credential $mycreds -Identifier 'Foo'
|
||||
$writtenItem = Get-CredentialStoreItem -Path $tmpCS -RemoteHost $RemoteHost -Identifier 'Foo'
|
||||
($writtenItem.UserName -eq $UserName) -and ($writtenItem.Password.Length -gt 0) | Should -Be $true
|
||||
}
|
||||
}
|
||||
Context "Test optional parameter lookup" {
|
||||
Mock Get-Credential {
|
||||
$UserName = 'testuser'
|
||||
$Password = ConvertTo-SecureString -String "mypasswd" -AsPlainText -Force
|
||||
return [PSCredential]::new($UserName, $Password)
|
||||
|
||||
}
|
||||
It "Test missing Credential" {
|
||||
$tmpCS = 'C:\CredentialStore.json'
|
||||
New-CredentialStoreItem -Path $tmpCs -Shared -RemoteHost 'foobar3'
|
||||
$writtenItem = Get-CredentialStoreItem -Path $tmpCS -Shared -RemoteHost 'foobar3'
|
||||
$writtenItem.UserName | Should -Be "testuser"
|
||||
}
|
||||
}
|
||||
Context "General Exception handling" {
|
||||
Mock Test-CredentialStore {return $false}
|
||||
Mock Get-Credential {
|
||||
$UserName = 'myUser'
|
||||
$Password = ConvertTo-SecureString -String "mypasswd" -AsPlainText -Force
|
||||
return [PSCredential]::new($UserName, $Password)
|
||||
|
||||
}
|
||||
It "Missing CredentialStore should throw" {
|
||||
{ New-CredentialStoreItem -Path 'C:\missingStore.json' -RemoteHost 'notrelevant' } | Should -Throw "Could not add anything"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -14,7 +14,7 @@ Else {
|
||||
}
|
||||
|
||||
# load additional functions defined in the repository. Replace the expression <FunctionName>.
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Test-CredentialStore.ps1" -Recurse).FullName
|
||||
#. (Get-ChildItem -Path $RepoRoot -Filter "Test-CredentialStore.ps1" -Recurse).FullName
|
||||
|
||||
#endregion HEADER
|
||||
|
||||
@ -33,5 +33,15 @@ Describe "Get-CredentialStore" {
|
||||
|
||||
{Get-CredentialStore -Path $TestCredentialStore} | Should Not Throw
|
||||
}
|
||||
It "Test3: Not existing path should return false" {
|
||||
{ Get-CredentialStore -Path 'C:\foobar\CredentialStore.json' -Shared }| Should -Throw "Could not find the CredentialStore."
|
||||
}
|
||||
}
|
||||
Context "Testing invalid json data" {
|
||||
Mock Test-CredentialStore {return $true}
|
||||
Mock Get-Content {return '"foo":"bar",'}
|
||||
It "Should throw with invalid CredentialStore" {
|
||||
{ Get-Credentialstore -Path "C:\dummy.json"} | Should -Throw "Unknown CredentialStore format. Invalid JSON file."
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ Else {
|
||||
}
|
||||
|
||||
# load additional functions defined in the repository. Replace the expression <FunctionName>.
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Test-CredentialStore.ps1" -Recurse).FullName
|
||||
#. (Get-ChildItem -Path $RepoRoot -Filter "Test-CredentialStore.ps1" -Recurse).FullName
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Test-ChallengeFile.ps1" -Recurse).FullName
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Set-ChallengeFile.ps1" -Recurse).FullName
|
||||
. (Get-ChildItem -Path $RepoRoot -Filter "Get-RandomKey.ps1" -Recurse).FullName
|
||||
@ -49,7 +49,7 @@ Describe "New-CredentialStore" {
|
||||
It "Test1: Create new private CredentialStore" {
|
||||
New-CredentialStore
|
||||
$result = Test-Path -Path $pCS
|
||||
$CS = Get-Content -Path $pCS -Raw | ConvertFrom-Json -ErrorAction SilentlyContinue
|
||||
$CS = Get-Content -Path $pCS -Raw | ConvertFrom-Json
|
||||
($result -eq $True) -and ($CS.Type -eq "Private") | Should Be $True
|
||||
}
|
||||
It "Test2: Try to override private Store" {
|
||||
@ -92,6 +92,12 @@ Describe "New-CredentialStore" {
|
||||
{New-CredentialStore -Path $pCS -Shared -Force} | Should Not Throw
|
||||
}
|
||||
}
|
||||
Context "Test exception handling" {
|
||||
Mock Out-File {throw "foobar exception"}
|
||||
It "JSON Converstion should fail and throw" {
|
||||
{ New-CredentialStore -Path "C:\dummy.json"} | Should -Throw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Cleanup test stores and restore existing ones.
|
@ -36,5 +36,14 @@ Describe "Test-CredentialStore" {
|
||||
$res | Should Be $False
|
||||
$WarningPreference = $oWarningPreference
|
||||
}
|
||||
It "Test4: Not existing path should return false" {
|
||||
Test-CredentialStore -Path 'C:\foobar\CredentialStore.json' | Should -Be $false
|
||||
}
|
||||
It "Test5: testing private CredentialStore path" {
|
||||
if (Test-Path -Path ("{0}\CredentialStore.json" -f $env:APPDATA) ) {
|
||||
Remove-Item -Path ("{0}\CredentialStore.json" -f $env:APPDATA)
|
||||
}
|
||||
Test-CredentialStore | Should -Be $false
|
||||
}
|
||||
}
|
||||
}
|
@ -95,7 +95,7 @@ Function Invoke-AppVeyorTests() {
|
||||
Details = 'Now running all test found in .\tests\ dir.'
|
||||
}
|
||||
Add-AppveyorMessage @MsgParams
|
||||
$testresults = Invoke-Pester -Path ".\tests\*" -ExcludeTag 'Disabled' -PassThru
|
||||
$testresults = Invoke-Pester -Path ( Get-ChildItem -Path ".\tests\*.Tests.ps1" -Recurse | Sort-Object -Property Name ) -ExcludeTag 'Disabled' -PassThru
|
||||
ForEach ($Item in $testresults.TestResult) {
|
||||
Switch ($Item.Result) {
|
||||
"Passed" {
|
||||
@ -154,7 +154,6 @@ Function Invoke-CoverageReport() {
|
||||
[String]$RepoToken = $Env:CoverallsToken
|
||||
)
|
||||
|
||||
Import-Module ('.\src\{0}.psm1' -f $CALLSIGN) -Verbose -Force
|
||||
$FileMap = New-PesterFileMap -SourceRoot '.\src' -PesterRoot '.\tests'
|
||||
$CoverageReport = New-CoverageReport -PesterFileMap $FileMap -RepoToken $RepoToken
|
||||
Write-Host "CoverageReport JSON:" -ForegroundColor Yellow
|
||||
|
Reference in New Issue
Block a user