Created
October 9, 2018 16:35
-
-
Save mczerniawski/b5a7d104b86dadb656fda851c009231a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Parameter(Mandatory, HelpMessage = 'Provide Cluster Name', | |
ValueFromPipeline, ValueFromPipelineByPropertyName)] | |
[ValidateNotNullOrEmpty()] | |
[System.String] | |
$Cluster, | |
[Parameter(Mandatory = $false, HelpMessage = 'Provide Credentials for Cluster', | |
ValueFromPipeline, ValueFromPipelineByPropertyName)] | |
[System.Management.Automation.PSCredential] | |
$Credential, | |
#region PSSession parameters | |
$connectionParams = @{ | |
ComputerName = $Cluster | |
} | |
if ($PSBoundParameters.ContainsKey('Credential')) { | |
$connectionParams.Credential = $Credential | |
Write-Verbose -Message "Processing with provided credentials {$($Credential.UserName)}" | |
} | |
else { | |
Write-Verbose -Message "Processing with default credentials of user {$($env:USERNAME)}" | |
} | |
$ClusterSession = New-PSSession @connectionParams -ErrorAction Stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment