forked from OCram85/PSCredentialStore
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
cb11209702 | |||
6659c2b317 | |||
599232ecec | |||
855cb920c8 | |||
8c92028b09 |
38
README.md
38
README.md
@ -1,21 +1,26 @@
|
||||
| AppVeyor Overall | AppVeyor Master | AppVeyor Dev | Coveralls.io | Download |
|
||||
| :--------------: | :-------------: | :----------: | :-----------: | :--------:|
|
||||
| [](https://ci.appveyor.com/project/OCram85/PSCredentialStore) | [](https://ci.appveyor.com/project/OCram85/PSCredentialStore/branch/master) | [](https://ci.appveyor.com/project/OCram85/PSCredentialStore/branch/dev) | [](https://coveralls.io/github/OCram85/PSCredentialStore?branch=master) | [](https://www.powershellgallery.com/packages/PSCredentialStore)
|
||||
[](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://www.powershellgallery.com/packages/PSCredentialStore)
|
||||
[](https://www.powershellgallery.com/packages/PSCredentialStore)
|
||||
|
||||

|
||||

|
||||
|
||||
General
|
||||
=======
|
||||
|
||||
The PSCredentialStore is an simple credential manager for PSCredentials. It stores multiple credential objects in a
|
||||
simple json file. You can choose between a private and shared store. The private one exists in your profile and can
|
||||
The PSCredentialStore is a simple credential manager for PSCredentials. 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
|
||||
script without exposing them as plain text.
|
||||
scripts without exposing them as plain text.
|
||||
|
||||
**The shared store isn't 100% secure and I don't recommend using it in production!**
|
||||
|
||||
PSCredentialStore was developed to simplify the delegation of complex powershell scripts. In this case you often
|
||||
need to store credentials for non interactive usage like in scheduled tasks.
|
||||
|
||||
To get started read the [about_PSCredentialStore](/src/en-US/about_PSCredential.help.txt) page.
|
||||
For more details read the [about_PSCredentialStore](/src/en-US/about_PSCredential.help.txt) page.
|
||||
|
||||
Installation
|
||||
============
|
||||
@ -32,27 +37,27 @@ Manual Way
|
||||
|
||||
* Take a look at the [Latest Release](https://github.com/OCram85/PSCredentialStore/releases/latest) page.
|
||||
* Download the `PSCredentialStore.zip`.
|
||||
* Unpack the Zip and put it in your Powershell Module path.
|
||||
* Unpack the zip file and put it in your Powershell module path.
|
||||
* Don't forget to change the NTFS permission flag in the context menu.
|
||||
* Start with `Import-Module PSCredentialStore`
|
||||
|
||||
Quick Start
|
||||
-----------
|
||||
|
||||
**1.** First we need a blank CredentialStore. You can decide between a *private* or *shared* store. The private
|
||||
**1.** First we need a blank credential store. You can decide between a *private* or *shared* store. The private
|
||||
Credential Store can only be accessed with your profile on the machine you created it.
|
||||
```powershell
|
||||
# Private Credential Store
|
||||
# Private credential store
|
||||
New-CredentialStore
|
||||
|
||||
# Shared Credential Store
|
||||
# Shared credential rtore
|
||||
New-CredentialStore -Shared
|
||||
|
||||
#Shared CredentialStore in custom Location
|
||||
#Shared credential store in custom Location
|
||||
New-CredentialStore -Shared -Path 'C:\CredentialStore.json'
|
||||
```
|
||||
|
||||
**2.** Now you can manage your CredentialStoreItems:
|
||||
**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'
|
||||
@ -62,8 +67,8 @@ $DCCreds = Get-CredentialStoreItem -RemoteHost 'dc01.myside.local' -Identifier '
|
||||
Invoke-Command -ComputerName 'dc01.myside.local' -Credential $DCCreds -ScripBlock {Get-Process}
|
||||
```
|
||||
|
||||
The CredentialStore contains also a simple function to establish a connection with several systems or protocols.
|
||||
If you have already installed the underlying framework your can connect to:
|
||||
The credential store contains also a simple function to establish a connection with several systems or protocols.
|
||||
If you have already installed the underlying framework / modules, you can connect these endpoints:
|
||||
|
||||
* **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)
|
||||
@ -73,6 +78,8 @@ If you have already installed the underlying framework your can connect to:
|
||||
* Required Modules: [`DataONTAP`](http://mysupport.netapp.com/tools/info/ECMLP2310788I.html?productID=61926)
|
||||
* **VMware** - Establish a connection to a VMware vCenter or ESXi host.
|
||||
* 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)
|
||||
|
||||
Here are some basic examples:
|
||||
|
||||
@ -81,4 +88,5 @@ Connect-To -RemoteHost "ucs.myside.local" -Type CiscoUcs
|
||||
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
|
||||
Connect-To -RemoteHost "fas.myside.local" -Type NetAppFAS
|
||||
Connect-To -RemoteHost "esx01.myside.local" -Type VMware
|
||||
Connect-To -RemoteHost "vcr.myside.local" -Type CisServer
|
||||
```
|
||||
|
25
appveyor.yml
25
appveyor.yml
@ -1,4 +1,4 @@
|
||||
version: 0.1.{build}
|
||||
version: 0.2.0.{build}
|
||||
|
||||
branches:
|
||||
only:
|
||||
@ -14,15 +14,8 @@ image: Visual Studio 2017
|
||||
|
||||
# Install pester module and init the Appveyor support.
|
||||
install:
|
||||
- ps: Install-PackageProvider -Name NuGet -MinimumVersion '2.8.5.201' -Force -Verbose
|
||||
- ps: Import-PackageProvider NuGet -MinimumVersion '2.8.5.201' -Force
|
||||
- ps: Install-Module -Name 'Pester' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber
|
||||
- ps: Update-Module 'Pester'
|
||||
- ps: Install-Module -Name 'posh-git' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber
|
||||
- ps: Update-Module 'posh-git'
|
||||
- ps: Install-Module -Name 'PSCoverage' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber
|
||||
- ps: Import-Module 'PSCoverage'
|
||||
- ps: Import-Module .\tools\AppVeyor.psm1
|
||||
- ps: Invoke-InstallDependencies -Verbose
|
||||
|
||||
environment:
|
||||
NuGetToken:
|
||||
@ -43,14 +36,22 @@ test_script:
|
||||
- ps: Invoke-CoverageReport
|
||||
|
||||
deploy:
|
||||
#- provider: GitHub
|
||||
# auth_token:
|
||||
# secure: M+bBX5/nKdJB0eViP7xtrLVTwf3vGDUA9N2MMprZp2i+9ZR3CBVcJnSzJWUmalhB
|
||||
# artifact: PSCredentialStore.zip # upload all NuGet packages to release assets
|
||||
# draft: true
|
||||
# prerelease: true
|
||||
# on:
|
||||
# branch: dev
|
||||
- provider: GitHub
|
||||
auth_token:
|
||||
secure: M+bBX5/nKdJB0eViP7xtrLVTwf3vGDUA9N2MMprZp2i+9ZR3CBVcJnSzJWUmalhB
|
||||
artifact: PSCredentialStore.zip # upload all NuGet packages to release assets
|
||||
draft: false
|
||||
prerelease: true
|
||||
prerelease: false
|
||||
on:
|
||||
branch: master # release from master branch only
|
||||
branch: master # build release on master branch changes
|
||||
|
||||
after_deploy:
|
||||
- ps: Invoke-AppVeyorPSGallery
|
||||
- ps: Invoke-AppVeyorPSGallery -OnBranch 'master'
|
||||
|
@ -34,12 +34,28 @@ Establish a connection to the selected host using a stored CredentialStoreItem.
|
||||
Connect-To -RemoteHost "ucs.myside.local" -Type CiscoUcs
|
||||
```
|
||||
|
||||
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
|
||||
Connect-To -RemoteHost "fas.myside.local" -Type NetAppFAS
|
||||
Connect-To -RemoteHost "esx01.myside.local" -Type VMware
|
||||
|
||||
### -------------------------- EXAMPLE 2 --------------------------
|
||||
```
|
||||
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 3 --------------------------
|
||||
```
|
||||
Connect-To -RemoteHost "fas.myside.local" -Type NetAppFAS
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 4 --------------------------
|
||||
```
|
||||
Connect-To -RemoteHost "esx01.myside.local" -Type VMware
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 5 --------------------------
|
||||
```
|
||||
Connect-To -RemoteHost "vCenter.myside.local" -Type CisServer
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 6 --------------------------
|
||||
```
|
||||
$MyCreds = Get-Credential
|
||||
```
|
||||
|
||||
@ -88,6 +104,7 @@ Currently implemented targets are:
|
||||
- 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
|
||||
@ -164,9 +181,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 : PSFTP, PowerCLI
|
||||
Requires :
|
||||
\`\`\`
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
|
@ -46,6 +46,11 @@ Disconnect-From -RemoteHost "esx01.myside.local" -Type VMware
|
||||
Disconnect-From -RemoteHost "esx01.myside.local" -Type VMware -Force:$True
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 6 --------------------------
|
||||
```
|
||||
Disconnect-From -RemoteHost "vcenter.myside.local" -Type CisServer
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -RemoteHost
|
||||
@ -66,10 +71,11 @@ 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.
|
||||
- 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.
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
@ -110,9 +116,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
### [None]
|
||||
|
||||
## NOTES
|
||||
File Name : Disconnect-To.ps1
|
||||
\`\`\`
|
||||
File Name : Disconnect-From.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
\`\`\`
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
|
@ -82,9 +82,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
|
||||
|
||||
|
@ -112,9 +112,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
### [System.Management.Automation.PSCredential]
|
||||
|
||||
## NOTES
|
||||
\`\`\`
|
||||
File Name : Get-CredentialStoreItem.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
\`\`\`
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
|
@ -112,9 +112,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
### [System.Management.Automation.PSCredential]
|
||||
|
||||
## NOTES
|
||||
\`\`\`
|
||||
File Name : Get-CredentialStoreItem.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
\`\`\`
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
|
@ -130,9 +130,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
|
||||
|
||||
|
@ -113,9 +113,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
|
||||
|
||||
|
@ -113,9 +113,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
|
||||
|
||||
|
@ -78,9 +78,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
|
||||
## OUTPUTS
|
||||
|
||||
## NOTES
|
||||
\`\`\`
|
||||
File Name : Test-CredentialStore.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
\`\`\`
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
|
@ -121,9 +121,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
|
||||
|
||||
|
@ -1 +1 @@
|
||||
theme: jekyll-theme-modernist
|
||||
theme: jekyll-theme-midnight
|
@ -70,15 +70,18 @@ If you have already installed the underlying framework your can connect to:
|
||||
* Required Modules: [`DataONTAP`](http://mysupport.netapp.com/tools/info/ECMLP2310788I.html?productID=61926)
|
||||
* **VMware** - Establish a connection to a VMware vCenter or ESXi host.
|
||||
* 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))
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```powershell
|
||||
Connect-To -RemoteHost "ucs.myside.local" -Type CiscoUcs
|
||||
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
|
||||
Connect-To -RemoteHost "fas.myside.local" -Type NetAppFAS
|
||||
Connect-To -RemoteHost "esx01.myside.local" -Type VMware
|
||||
Connect-To -RemoteHost "vcr.myside.local" -Type CisServer
|
||||
```
|
||||
|
||||
# NOTE
|
||||
|
||||
|
||||
|
@ -19,10 +19,11 @@ function Get-ChallengeFile {
|
||||
.\Get-RandomKey -Path "C:\TMP\Challenge.bin"
|
||||
|
||||
.NOTES
|
||||
```
|
||||
File Name : Get-ChallengeFile.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
|
||||
```
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
|
@ -19,6 +19,9 @@ function Connect-To {
|
||||
- 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.
|
||||
|
||||
.PARAMETER Credentials
|
||||
Use this parameter to bypass the stored credentials. Without this parameter Connect-To tries to read the
|
||||
@ -40,10 +43,25 @@ function Connect-To {
|
||||
|
||||
.EXAMPLE
|
||||
Connect-To -RemoteHost "ucs.myside.local" -Type CiscoUcs
|
||||
|
||||
.EXAMPLE
|
||||
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
|
||||
|
||||
.EXAMPLE
|
||||
Connect-To -RemoteHost "fas.myside.local" -Type NetAppFAS
|
||||
|
||||
.EXAMPLE
|
||||
Connect-To -RemoteHost "esx01.myside.local" -Type VMware
|
||||
|
||||
.EXAMPLE
|
||||
Connect-To -RemoteHost "vCenter.myside.local" -Type CisServer
|
||||
|
||||
.EXAMPLE
|
||||
Connect-To -RemoteHost "exchange01.myside.local" -Type ExchangeHTTP
|
||||
|
||||
.EXAMPLE
|
||||
Connect-To -RemoteHost "exchange01.myside.local" -Type ExchangeHTTPS
|
||||
|
||||
.EXAMPLE
|
||||
$MyCreds = Get-Credential
|
||||
Connect-To -RemoteHost "vcr01.myside.local" -Type VMware -Credentials $MyCreds
|
||||
@ -53,25 +71,26 @@ function Connect-To {
|
||||
.NOTES
|
||||
File Name : Connect-To.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires : PSFTP, PowerCLI
|
||||
Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
|
||||
[CmdletBinding(DefaultParameterSetName = "Private")]
|
||||
param(
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
||||
[String]$RemoteHost,
|
||||
[string]$RemoteHost,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Shared")]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = "Private")]
|
||||
[String]$Identifier,
|
||||
[string]$Identifier,
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Shared")]
|
||||
[Parameter(Mandatory = $true, ParameterSetName = "Private")]
|
||||
[ValidateSet("CiscoUcs", "FTP", "NetAppFAS", "VMware")]
|
||||
[String]$Type,
|
||||
[ValidateSet('CiscoUcs', 'FTP', 'NetAppFAS', 'VMware', 'CisServer', 'ExchangeHTTP', 'ExchangeHTTPS')]
|
||||
[string]$Type,
|
||||
|
||||
[Parameter(Mandatory = $False, ParameterSetName = "Shared")]
|
||||
[Parameter(Mandatory = $False, ParameterSetName = "Private")]
|
||||
@ -79,10 +98,10 @@ function Connect-To {
|
||||
|
||||
[Parameter(Mandatory = $False, ParameterSetName = "Shared")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[String]$Path = "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData,
|
||||
[string]$Path = "{0}\PSCredentialStore\CredentialStore.json" -f $env:ProgramData,
|
||||
|
||||
[Parameter(Mandatory = $false, ParameterSetNAme = "Shared")]
|
||||
[Switch]$Shared
|
||||
[switch]$Shared
|
||||
)
|
||||
|
||||
begin {
|
||||
@ -199,6 +218,60 @@ function Connect-To {
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
"CisServer" {
|
||||
try {
|
||||
Connect-CisServer -Server $RemoteHost -Credential $creds -ErrorAction Stop | Out-Null
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
"ExchangeHTTP" {
|
||||
try {
|
||||
$ConnectionParams = @{
|
||||
ConnectionURI = "http://{0}/powershell" -f $RemoteHost
|
||||
ConfigurationName = 'Microsoft.Exchange'
|
||||
Credential = $creds
|
||||
ErrorAction = 'Stop'
|
||||
}
|
||||
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
|
||||
$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"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
"ExchangeHTTPS" {
|
||||
try {
|
||||
$ConnectionParams = @{
|
||||
ConnectionURI = "https://{0}/powershell" -f $RemoteHost
|
||||
ConfigurationName = 'Microsoft.Exchange'
|
||||
Credential = $creds
|
||||
ErrorAction = 'Stop'
|
||||
}
|
||||
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
|
||||
$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"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
default {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
|
@ -15,11 +15,13 @@ function Disconnect-From {
|
||||
|
||||
.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.
|
||||
|
||||
- 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
|
||||
.PARAMETER Force
|
||||
Force the disconnect, even if the disconnect would fail.
|
||||
|
||||
@ -44,8 +46,17 @@ function Disconnect-From {
|
||||
.EXAMPLE
|
||||
Disconnect-From -RemoteHost "esx01.myside.local" -Type VMware -Force:$True
|
||||
|
||||
.EXAMPLE
|
||||
Disconnect-From -RemoteHost "vcenter.myside.local" -Type CisServer
|
||||
|
||||
.EXAMPLE
|
||||
Disconnect-From -RemoteHost "exchange01.myside.local" -Type ExchangeHTTP
|
||||
|
||||
.EXAMPLE
|
||||
Disconnect-From -RemoteHost "exchange01.myside.local" -Type ExchangeHTTPS
|
||||
|
||||
.NOTES
|
||||
File Name : Disconnect-To.ps1
|
||||
File Name : Disconnect-From.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
|
||||
@ -59,14 +70,14 @@ function Disconnect-From {
|
||||
[string]$RemoteHost,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateSet("CiscoUcs", "FTP", "NetAppFAS", "VMware")]
|
||||
[ValidateSet('CiscoUcs', 'FTP', 'NetAppFAS', 'VMware', 'CisServer', 'ExchangeHTTP', 'ExchangeHTTPS')]
|
||||
[string]$Type,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[switch]$Force
|
||||
)
|
||||
|
||||
switch ($Type) {
|
||||
switch -Regex ($Type) {
|
||||
"VMware" {
|
||||
try {
|
||||
if ($Force) {
|
||||
@ -85,7 +96,25 @@ function Disconnect-From {
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
"CisServer" {
|
||||
try {
|
||||
if ($Force) {
|
||||
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop -Force:$true
|
||||
}
|
||||
else {
|
||||
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
|
||||
catch {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
# Check for an existing WinSCP Session var
|
||||
"FTP" {
|
||||
@ -111,6 +140,7 @@ function Disconnect-From {
|
||||
Write-Verbose @MessageParams
|
||||
$Global:CurrentNcController = $null
|
||||
}
|
||||
|
||||
catch {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
@ -135,6 +165,19 @@ function Disconnect-From {
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
"ExchangeHTTP*" {
|
||||
try {
|
||||
Get-Variable -Name 'PSExchangeRemote' -Scope Global -ErrorAction Stop
|
||||
Remove-PSSession -Session $Global:PSExchangeRemote -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
$MessageParams = @{
|
||||
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
Write-Error @MessageParams
|
||||
}
|
||||
}
|
||||
default {
|
||||
# Write a error message to the log.
|
||||
$MessageParams = @{
|
||||
|
114
src/Connection/Test-CSConnection.ps1
Normal file
114
src/Connection/Test-CSConnection.ps1
Normal file
@ -0,0 +1,114 @@
|
||||
function Test-CSConnection {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Returns the connection state of a given type to the remote host.
|
||||
|
||||
.DESCRIPTION
|
||||
Use this script to check a connection which was established with the `Connect-To` cmdlet.
|
||||
|
||||
.PARAMETER RemoteHost
|
||||
Define the remote host you would like to check.
|
||||
|
||||
.Parameter Type
|
||||
Define the connection type you would like to check. See the `Connect-To` documentation
|
||||
for valid type values.
|
||||
|
||||
.INPUTS
|
||||
[None]
|
||||
|
||||
.OUTPUTS
|
||||
[Boolean]
|
||||
|
||||
.EXAMPLE
|
||||
.\Test-CMConnection -RemoteHost "r0-i01-vcr01.p0r.kivbf-cloud.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([boolean])]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$RemoteHost,
|
||||
|
||||
[Parameter(Mandatory = $True)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[ValidateSet("CiscoUcs", "FTP", "NetAppFAS", "VMware")]
|
||||
[string]$Type
|
||||
)
|
||||
|
||||
switch ($Type) {
|
||||
'VMware' {
|
||||
try {
|
||||
$Conn = Get-Variable -Name DefaultVIServer -Scope Global -ErrorAction Stop
|
||||
}
|
||||
catch [System.Management.Automation.ItemNotFoundException] {
|
||||
$MsgParams = @{
|
||||
Message = "There is no open PowerCLI VMware connection bound to 'DefaultVIServer'."
|
||||
}
|
||||
Write-Verbose @MsgParams
|
||||
return $false
|
||||
}
|
||||
if ($Conn.Value.Name -eq $RemoteHost) {
|
||||
if ($Conn.Value.IsConnected) {
|
||||
$MsgParams = @{
|
||||
Message = "'DefaultVIServer' found. Connection to given remote host already established."
|
||||
}
|
||||
Write-Verbose @MsgParams
|
||||
return $True
|
||||
}
|
||||
else {
|
||||
$MsgParams = @{
|
||||
Message = "'DefaultVIServer' found. RemoteHost matches but the connection is closed."
|
||||
}
|
||||
Write-Verbose @MsgParams
|
||||
return $false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
'CiscoUcs' {
|
||||
$MsgParams = @{
|
||||
ErrorAction = "Stop"
|
||||
Message = "CiscoUCS connection test is not implemented yet!"
|
||||
}
|
||||
Write-Error @MsgParams
|
||||
return $false
|
||||
}
|
||||
|
||||
'FTP' {
|
||||
$MsgParams = @{
|
||||
ErrorAction = "Stop"
|
||||
Message = "FTP connection test is not implemented yet!"
|
||||
}
|
||||
Write-Error @MsgParams
|
||||
return $false
|
||||
}
|
||||
|
||||
'NetAppFAS' {
|
||||
$MsgParams = @{
|
||||
ErrorAction = "Stop"
|
||||
Message = "NetAppFAS connection test is not implemented yet!"
|
||||
}
|
||||
Write-Error @MsgParams
|
||||
return $false
|
||||
}
|
||||
|
||||
# The Default section will never be shown as long as the powershell framework isn't broken.
|
||||
Default {
|
||||
$MsgParams = @{
|
||||
ErrorAction = "Stop"
|
||||
Message = "Panic: There is an invalid type value! This error should never be thrown."
|
||||
}
|
||||
Write-Error @MsgParams
|
||||
return $false
|
||||
}
|
||||
}
|
||||
}
|
@ -26,6 +26,12 @@
|
||||
"Modules": [
|
||||
"DataONTAP"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "CisServer",
|
||||
"Modules": [
|
||||
"VMware.VimAutomation.Cis.Core"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -19,9 +19,11 @@ function Get-RandomKey {
|
||||
.\Get-RandomKey -Size 24
|
||||
|
||||
.NOTES
|
||||
```
|
||||
File Name : Get-RandomKey.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
```
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
|
@ -40,9 +40,11 @@ function Resolve-Dependency {
|
||||
}
|
||||
|
||||
.NOTES
|
||||
```
|
||||
File Name : ResolveDependency.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
```
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
|
@ -34,9 +34,11 @@ function Test-Module {
|
||||
.\Test-Dependency -Name 'VMware.PowerCLI' -Type 'Module' -StopIfFails
|
||||
|
||||
.NOTES
|
||||
```
|
||||
File Name : Get-RandomKey.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
```
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
|
@ -31,10 +31,11 @@ function Get-CredentialStoreItem {
|
||||
$myCreds = Get-CredentialStoreItem -Path "C:\TMP\mystore.json" -RemoteHost "esx01.myside.local"
|
||||
|
||||
.NOTES
|
||||
```
|
||||
File Name : Get-CredentialStoreItem.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
|
||||
```
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
|
@ -31,10 +31,11 @@ function New-CredentialStoreItem {
|
||||
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
|
||||
#>
|
||||
|
@ -31,9 +31,11 @@ function Remove-CredentialStoreItem {
|
||||
Remove-CredentialStoreItem -Path "C:\TMP\mystore.json" -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
|
||||
|
@ -30,9 +30,11 @@ function Set-CredentialStoreItem {
|
||||
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
|
||||
|
@ -37,9 +37,11 @@ function Test-CredentialStoreItem() {
|
||||
}
|
||||
|
||||
.NOTES
|
||||
```
|
||||
File Name : Test-CredentialStoreItem.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
```
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
|
@ -74,6 +74,7 @@
|
||||
# Connection Group
|
||||
'Connect-To',
|
||||
'Disconnect-From',
|
||||
'Test-CSConnection',
|
||||
# Item Group
|
||||
'Get-CredentialStoreItem',
|
||||
'Set-CredentialStoreItem',
|
||||
|
@ -25,10 +25,11 @@ function Get-CredentialStore {
|
||||
$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
|
||||
#>
|
||||
|
@ -41,10 +41,11 @@ function New-CredentialStore {
|
||||
# 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
|
||||
#>
|
||||
|
@ -15,10 +15,11 @@ function Test-CredentialStore {
|
||||
can be decrypted across systems.
|
||||
|
||||
.NOTES
|
||||
```
|
||||
File Name : Test-CredentialStore.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
|
||||
```
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
|
@ -9,6 +9,32 @@
|
||||
$CALLSIGN = 'PSCredentialStore'
|
||||
Write-Host ("Callsign is: {0}" -f $CALLSIGN) -ForegroundColor Yellow
|
||||
|
||||
|
||||
Function Invoke-InstallDependencies() {
|
||||
[CmdletBinding()]
|
||||
Param()
|
||||
|
||||
Process {
|
||||
Try {
|
||||
Install-PackageProvider -Name NuGet -RequiredVersion '2.8.5.208' -Force -Verbose
|
||||
Import-PackageProvider -Name NuGet -RequiredVersion '2.8.5.208' -Force
|
||||
Install-Module -Name 'Pester' -Scope CurrentUser -RequiredVersion '4.0.8' -Force -SkipPublisherCheck -AllowClobber
|
||||
Install-Module -Name 'posh-git' -Scope CurrentUser -RequiredVersion '0.7.1' -Force -SkipPublisherCheck -AllowClobber
|
||||
Install-Module -Name 'PSCoverage' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber
|
||||
Import-Module -Name 'Pester', 'posh-git', 'PSCoverage'
|
||||
}
|
||||
Catch {
|
||||
$MsgParams = @{
|
||||
Message = 'Could not install the required dependencies!'
|
||||
Category = 'Error'
|
||||
Details = $_.Exception.Message
|
||||
}
|
||||
Add-AppveyorMessage @MsgParams
|
||||
Throw $MsgParams.Message
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Function Invoke-AppVeyorBumpVersion() {
|
||||
[CmdletBinding()]
|
||||
Param()
|
||||
@ -138,7 +164,11 @@ Function Invoke-CoverageReport() {
|
||||
|
||||
Function Invoke-AppVeyorPSGallery() {
|
||||
[CmdletBinding()]
|
||||
Param()
|
||||
Param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[String]$OnBranch
|
||||
)
|
||||
Expand-Archive -Path (".\bin\{0}.zip" -f $CALLSIGN) -DestinationPath ("C:\Users\appveyor\Documents\WindowsPowerShell\Modules\{0}\" -f $CALLSIGN) -Verbose
|
||||
Import-Module -Name $CALLSIGN -Verbose -Force
|
||||
Write-Host "Available Package Provider:" -ForegroundColor Yellow
|
||||
|
Reference in New Issue
Block a user