파워쉘 스크립트 예시입니다.
참고하시어 활용하시기 바랍니다.
[패스워드 코드 확인]
PS C:\> Read-Host "Password" -AsSecureString | ConvertFrom-SecureString | echo
Password: ************ #원격서버에서 접속할 계정의 패스워드를 입력
01000000d08c9ddaskjdhfkjahsdfjkhasdf01aksjdhfkjashd15d1118c7a00c04fc297eb01873019838200000007597a01219e314caa7074520be2be960000000002000021341200000003660000c000000010000000667e877561376fa203f4cae82a2cde2d0000000004800000a000000010000000df2dbb0bf5f409f5aa6905013e4298b120000000eb98d9ad8866171734e8329893288e26f4c5cad773e8b3cbd542a3b5e405ee5e14000000d14c3da80b6eabdd12998ac1ac2b421436f1185c
#위의 보이는 코드 값을 앞의 스크립트인 $MyPassword에 붙여넣기 하시면 됩니다.
[서버 1대 일때]
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.0.1" -Force
$MyPassword = "01000000d08c9ddaskjdhfkjahsdfjkhasdf01aksjdhfkjashd15d1118c7a00c04fc297eb01873019838200000007597a01219e314caa7074520be2be960000000002000021341200000003660000c000000010000000667e877561376fa203f4cae82a2cde2d0000000004800000a000000010000000df2dbb0bf5f409f5aa6905013e4298b120000000eb98d9ad8866171734e8329893288e26f4c5cad773e8b3cbd542a3b5e405ee5e14000000d14c3da80b6eabdd12998ac1ac2b421436f1185c"
$MyPassword = $MyPassword | ConvertTo-SecureString
$ObjectTypeName = "System.Management.Automation.PSCredential"
$MyCredential = New-Object -TypeName $ObjectTypeName -ArgumentList "administrator",$MyPassword
Invoke-Command -ComputerName "192.168.0.1" -Credential $MyCredential -Command { Get-PSDrive }
[서버 여러대 일때]
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.0.1,192.168.0.2" -Force
$MyPassword1 = "01000000d08c9ddaskjdhfkjahsdfjkhasdf01aksjdhfkjashd15d1118c7a00c04fc297eb01873019838200000007597a01219e314caa7074520be2be960000000002000021341200000003660000c000000010000000667e877561376fa203f4cae82a2cde2d0000000004800000a000000010000000df2dbb0bf5f409f5aa6905013e4298b120000000eb98d9ad8866171734e8329893288e26f4c5cad773e8b3cbd542a3b5e405ee5e14000000d14c3da80b6eabdd12998ac1ac2b421436f1185c"
$MyPassword2 = "01000000d08c9ddaskjdhfkjahsdfjkhasdf01aksjdhfkjashd15d1118c7a00c04fc297eb0100000007597a01219e314caa7074520be2be960000000002013241230000000012341230036600331300c000000010000000667e877561376fa203f4cae82a2cde2d0000000004800000a000000010000000df2dbb0bf5f409f5aa6905013e4298b120000000eb98d9ad8866171734e8329893288e26f4c5cad773e8b3cbd542a3b5e405ee5e14000000d14c3da80b6eabdd12998ac1ac2b421436f1185c"
$MyPassword1 = $MyPassword1 | ConvertTo-SecureString
$MyPassword2 = $MyPassword2 | ConvertTo-SecureString
$ObjectTypeName = "System.Management.Automation.PSCredential"
$MyCredential1 = New-Object -TypeName $ObjectTypeName -ArgumentList "administrator",$MyPassword1
$MyCredential2 = New-Object -TypeName $ObjectTypeName -ArgumentList "admin",$MyPassword2
Invoke-Command -ComputerName "192.168.0.1" -Credential $MyCredential1 -Command { Get-PSDrive }
Invoke-Command -ComputerName "192.168.0.2" -Credential $MyCredential2 -Command { Get-PSDrive }
'기술 노트 > Windows Server' 카테고리의 다른 글
윈도우즈 업데이트 서버 만들기 (WSUS) - 2 (0) | 2023.08.07 |
---|---|
윈도우즈 업데이트 서버 만들기 (WSUS) - 1 (0) | 2023.08.04 |
파워쉘 스크립트 실행 정책 (0) | 2023.08.04 |
파워쉘을 이용한 원격 서버 관리 (0) | 2023.08.03 |
컴퓨터 부팅 시간 확인하는 방법 (파워쉘) (0) | 2023.08.01 |