파워쉘 원격접속

2024. 10. 23. 16:32·Windows

 

$List = New-Object System.Collections.ArrayList;

$List.Add(@{
    "No" = 0;
    "Name" = "Server1";
    "IP" = "10.10.10.10";
});

$List.Add(@{
    "No" = 1;
    "Name" = "WindowsVM";
    "IP" = "10.10.10.11";
});

$lIST.Add(@{
    "No" = 2;
    "Name" = "RockyVM";
    "IP" = "10.10.10.12";
});

$lIST.Add(@{
    "No" = 3;
    "Name" = "UbuntuVM";
    "IP" = "10.10.10.13";
});

$lIST.Add(@{
    "No" = 4;
    "Name" = "Forti VPN";
    "IP" = "Login";
});

임의로 array를 생성함 (더미 데이터)

$ListPATH = "위 array를 저장한 파일";

. "$ListPATH";

$hr = "---------------------------";
Write-Host "아래의 목록 중 하나를 입력해 주세요.";
Write-Host "";

foreach ( $name in $List ) {
    $index = $List.IndexOf($name);
    $No    = $name.No;
    Write-Host "No : "$name.No;
    Write-Host "Name : "$name.Name;
    # Write-Host "IP : "$name.IP;
    Write-Host $hr;
}

function Access-RDP {
    param (
        [Parameter(Mandatory=$true)] [String] $No
        # [Parameter(Mandatory=$true)] [String] $MultimonYN  # 클라이언트와 같은 환경, 듀얼 모니터 구성 여부
    );

    $rdpInfo = $List | where { $_.No -eq "$No" -and $_.No -ne $null };
    $rdpIP = $rdpInfo.IP;
    $rdpName = $rdpInfo.Name;

    if ( $rdpName -ieq "forti VPN") {  # VPN을 선택할 경우 VPN 링크 프로그램 경로를 따라감
        $VPNPath = C:\ProgramData\Microsoft\Windows\"Start Menu"\Programs\FortiClient\FortiClient.lnk;
        $VPNPath;
        exit;
    }

    $selectyn = Read-Host "Do you want to use the same environment as the client? (Y/N)";
    if ($selectyn -ieq "Y" ) {
        mstsc -multimon -v $rdpIP ;
       
    } else {
        <# Action when this condition is true #>
        mstsc -v $rdpIP ;
    }

    return $rdpInfo;
}

Access-RDP;

그래서 실제로 실행을 해보면

요렇게 ip가 박힌 상태로 암호만 편리하게 입력할 수 있음

저작자표시 비영리

'Windows' 카테고리의 다른 글

ODBC를 통한 Mariadb 연결 스크립트  (0) 2024.11.13
일주일 업무일지를 생성하는 파워쉘 스크립트  (1) 2024.10.31
Hyper-v VM 생성하기 2탄 (Powershell)  (0) 2024.09.25
Hyper-v VM 생성하기 1탄 (GUI)  (0) 2024.09.24
'Windows' 카테고리의 다른 글
  • ODBC를 통한 Mariadb 연결 스크립트
  • 일주일 업무일지를 생성하는 파워쉘 스크립트
  • Hyper-v VM 생성하기 2탄 (Powershell)
  • Hyper-v VM 생성하기 1탄 (GUI)
ssnong
ssnong
캠핑 맛집 여행 윈도우 리눅스 PHP DB 등 기록 공간입니다
  • ssnong
    호슐랭
    ssnong
  • 전체
    오늘
    어제
    • 분류 전체보기 (42)
      • Linux (21)
        • ubuntu (4)
        • Rocky 8.10 (16)
      • Windows (5)
      • git (3)
      • Lang (3)
        • javascript (3)
        • PHP (0)
      • Database (3)
        • MySQL8.0 (2)
        • MariaDB (1)
        • PostgreSQL(17.2) (0)
      • AWS (1)
      • ERROR! (4)
  • 링크

    • 일상은 여기서!
  • 공지사항

  • 인기 글

  • 태그

    Linux
    rocky postgresql설치
    git pull
    linux nft
    hyper-v vm 생성
    rocky 8 postgresql 설치
    리눅스 nft
    postgresql.conf 설정
    nftables
    리눅스 nftables
    pg_hba.conf 설정
    rocky
    rocky nftables
    linux nftables
    ssh 접속
    nginx php 소켓통신
    git push
    linux postgresql설치
    리눅스
    centos nftables
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.0
ssnong
파워쉘 원격접속
상단으로

티스토리툴바