Skip to content

Instantly share code, notes, and snippets.

@mczerniawski
Created October 9, 2018 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mczerniawski/b5a7d104b86dadb656fda851c009231a to your computer and use it in GitHub Desktop.
Save mczerniawski/b5a7d104b86dadb656fda851c009231a to your computer and use it in GitHub Desktop.
[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