Functions/Open-SshToGateway.ps1


function Open-SshToGateway {
    [CmdletBinding()]
    param (
        #[Parameter(Mandatory)] [string] $ParameterName
    )

    $GwVm = "JT-Gateway2"

    switch ($env:COMPUTERNAME) {
        "14X1134" { $VMSwitch = "WAN_NAT" }
        "ZOLDER" { $VMSwitch = "Ext" }
        "RAM010328" { $VMSwitch = "WAN_NAT" }
    }

    $GwVmSwtich = Get-VM $GwVm | Get-VMNetworkAdapter | Where-Object SwitchName -eq $VMSwitch

    $GwVmSwtich.IPAddresses | ForEach-Object {
        # if($_ -match "....") {
        if($_ -like "*.*.*.*") {
            $GwIP = $_
            $GwIP
        }
    }

    $GwIP

    ssh root@$GwIP


}