From 0b8348a7842d2b26d35a897b2d91f74afd8c93d3 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Fri, 20 Oct 2017 10:35:40 +0200 Subject: [PATCH] adds Connection Type CisServer --- src/Connection/Connect-To.ps1 | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Connection/Connect-To.ps1 b/src/Connection/Connect-To.ps1 index 740ee6a..7c172bf 100644 --- a/src/Connection/Connect-To.ps1 +++ b/src/Connection/Connect-To.ps1 @@ -19,6 +19,7 @@ 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. .PARAMETER Credentials Use this parameter to bypass the stored credentials. Without this parameter Connect-To tries to read the @@ -40,10 +41,19 @@ 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 $MyCreds = Get-Credential Connect-To -RemoteHost "vcr01.myside.local" -Type VMware -Credentials $MyCreds @@ -53,7 +63,7 @@ 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 @@ -70,7 +80,7 @@ function Connect-To { [Parameter(Mandatory = $true, ParameterSetName = "Shared")] [Parameter(Mandatory = $true, ParameterSetName = "Private")] - [ValidateSet("CiscoUcs", "FTP", "NetAppFAS", "VMware")] + [ValidateSet("CiscoUcs", "FTP", "NetAppFAS", "VMware", "CisServer")] [String]$Type, [Parameter(Mandatory = $False, ParameterSetName = "Shared")] @@ -199,6 +209,20 @@ 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 + } + } default { # Write a error message to the log. $MessageParams = @{