function Invoke-NcSsh { param ( [parameter(Mandatory=$false)] [string]$Name, [parameter(Mandatory=$true, HelpMessage="Command to Execute")] [string]$Command, [parameter(Mandatory=$false)] [System.Management.Automation.PSCredential]$Credential ) #puTTY installation Path to plink.exe. Modify it as per your installation. $env:Path += '; C:\Program Files (x86)\PuTTY\' #Set default security Protocol to SSLV3, TLS1.0, Tls1.1, Tls1.2 [System.Net.ServicePointManager]::SecurityProtocol = 'ssl3, Tls, Tls11, Tls12' if (!$Name) { $Name = (Get-NcCluster).NcController.Address.IPAddressToString } if (!$Credential) { $Credential = Get-WfaCredentials $Name $user = $Credential.username $Password = ConvertFromSecureToPlain -SecurePassword $Credential.Password } try { #Some plink versions accept yes/no Write-Output 'yes'| plink.exe -ssh $Name -l $user -pw $Password "?" > $null 2>&1 } catch { ## Some plink versions accept y/n Write-Output 'y' | plink.exe -ssh $Name -l $user -pw $Password "?" > $null 2>&1 } $result = & 'plink.exe' -ssh $Name -l $user -pw $Password $Command $obj = New-Object -TypeName PSObject $value = [string]$result Add-Member -InputObject $obj -MemberType NoteProperty -Name Value -Value $value return $obj }