Publish 0.2.0 (#12)

This commit is contained in:
OCram85 2017-12-22 08:10:37 +01:00 committed by GitHub
parent 6659c2b317
commit cb11209702
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 204 additions and 22 deletions

View File

@ -1,4 +1,4 @@
version: 0.1.{build}
version: 0.2.0.{build}
branches:
only:
@ -44,14 +44,14 @@ deploy:
# prerelease: true
# on:
# branch: dev
# - provider: GitHub
# auth_token:
# secure: M+bBX5/nKdJB0eViP7xtrLVTwf3vGDUA9N2MMprZp2i+9ZR3CBVcJnSzJWUmalhB
# artifact: PSCredentialStore.zip # upload all NuGet packages to release assets
# draft: false
# prerelease: false
# on:
# branch: master # release from master branch only
- provider: GitHub
auth_token:
secure: M+bBX5/nKdJB0eViP7xtrLVTwf3vGDUA9N2MMprZp2i+9ZR3CBVcJnSzJWUmalhB
artifact: PSCredentialStore.zip # upload all NuGet packages to release assets
draft: false
prerelease: false
on:
branch: master # build release on master branch changes
after_deploy:
# - ps: Invoke-AppVeyorPSGallery -OnBranch 'master'
- ps: Invoke-AppVeyorPSGallery -OnBranch 'master'

View File

@ -20,6 +20,8 @@ function Connect-To {
- 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
@ -54,6 +56,12 @@ function Connect-To {
.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
@ -61,29 +69,28 @@ function Connect-To {
Disconnect-From -RemoteHost "vcr01.myside.local" -Type VMware
.NOTES
```
File Name : Connect-To.ps1
Author : Marco Blessing - marco.blessing@googlemail.com
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", "CisServer")]
[String]$Type,
[ValidateSet('CiscoUcs', 'FTP', 'NetAppFAS', 'VMware', 'CisServer', 'ExchangeHTTP', 'ExchangeHTTPS')]
[string]$Type,
[Parameter(Mandatory = $False, ParameterSetName = "Shared")]
[Parameter(Mandatory = $False, ParameterSetName = "Private")]
@ -91,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 {
@ -225,6 +232,46 @@ function Connect-To {
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 = @{

View File

@ -20,6 +20,8 @@ function Disconnect-From {
- 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.
@ -47,12 +49,16 @@ function Disconnect-From {
.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-From.ps1
Author : Marco Blessing - marco.blessing@googlemail.com
Requires :
```
.LINK
https://github.com/OCram85/PSCredentialStore
@ -64,14 +70,14 @@ function Disconnect-From {
[string]$RemoteHost,
[Parameter(Mandatory = $true)]
[ValidateSet("CiscoUcs", "FTP", "NetAppFAS", "VMware", "CisServer")]
[ValidateSet('CiscoUcs', 'FTP', 'NetAppFAS', 'VMware', 'CisServer', 'ExchangeHTTP', 'ExchangeHTTPS')]
[string]$Type,
[Parameter(Mandatory = $false)]
[switch]$Force
)
switch ($Type) {
switch -Regex ($Type) {
"VMware" {
try {
if ($Force) {
@ -134,6 +140,7 @@ function Disconnect-From {
Write-Verbose @MessageParams
$Global:CurrentNcController = $null
}
catch {
# Write a error message to the log.
$MessageParams = @{
@ -158,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 = @{

View 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
}
}
}

View File

@ -74,6 +74,7 @@
# Connection Group
'Connect-To',
'Disconnect-From',
'Test-CSConnection',
# Item Group
'Get-CredentialStoreItem',
'Set-CredentialStoreItem',