winrm을 사용하여 신뢰할 수 있는 호스트 목록에 둘 이상의 시스템을 추가하는 방법
원격 시스템에서 powershell 명령을 실행하려면 원격 시스템을 호스트 시스템의 신뢰할 수 있는 호스트 목록에 추가해야 합니다.
다음 명령을 사용하여 시스템 A를 시스템 B의 신뢰할 수 있는 호스트에 추가합니다.
winrm set winrm/config/client ‘@{TrustedHosts="machineA"}’
머신 C, 머신 D를 머신 B의 신뢰할 수 있는 호스트 목록에 추가하는 방법
PSDrive를 사용하고 싶다WSMan:\.
신뢰의 획득호스트
Get-Item WSMan:\localhost\Client\TrustedHosts
신뢰할 수 있는 설정호스트
컴퓨터 이름의 단일 문자열을 쉼표로 구분하여 제공하다
Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'machineA,machineB'
또는 와일드카드
Set-Item WSMan:\localhost\Client\TrustedHosts -Value '*'
목록에 추가하다-Concatenate파라미터를 사용할 수 있습니다.
Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'machineC' -Concatenate
winrm set winrm/config/client '@{TrustedHosts="machineA,machineB"}'
Locc MICHEL이 제안한 답변은 신뢰할 수 있는 사람들에게 새로운 가치를 맹목적으로 씁니다.호스트 엔트리
우선 신뢰할 수 있는 질문을 하는 것이 더 나은 방법이 될 것 같습니다.호스트
Jeffery Hicks가 2010년에 게시한 바와 같이 먼저 Trusted에 대해 질문합니다.호스트 엔트리:
PS C:\> $current=(get-item WSMan:\localhost\Client\TrustedHosts).value
PS C:\> $current+=",testdsk23,alpha123"
PS C:\> set-item WSMan:\localhost\Client\TrustedHosts –value $current
신뢰할 수 있는 호스트, psTrusted를 조금 쉽게 처리할 수 있도록 모듈을 만들었습니다.호스트. 여기 GitHub에서 레포(repo)를 찾을 수 있습니다.신뢰할 수 있는 호스트와의 작업을 용이하게 하는 4가지 기능을 제공합니다.Add-TrustedHost,Clear-TrustedHost,Get-TrustedHost,그리고.Remove-TrustedHostPowerShell Gallery에서 다음 명령을 사용하여 모듈을 설치할 수 있습니다.
Install-Module psTrustedHosts -Force
이 예에서 호스트 'machineC' 및 'machineD'를 추가하려면 다음 명령을 사용합니다.
Add-TrustedHost 'machineC','machineD'
명확하게 말하면, 이 경우 이미 존재하는 호스트에 호스트 'machineC' 및 'machineD'가 추가되지만 기존 호스트는 덮어쓰지 않습니다.
그Add-TrustedHost명령어는 파이프라인 처리도 지원합니다.Remove-TrustedHostcommand)를 사용하여 다음 작업도 수행할 수 있습니다.
'machineC','machineD' | Add-TrustedHost
@Altered-Ego와 동일하지만 txt를 사용합니다.파일:
Get-Content "C:\ServerList.txt"
machineA,machineB,machineC,machineD
$ServerList = Get-Content "C:\ServerList.txt"
$currentTrustHost=(get-item WSMan:\localhost\Client\TrustedHosts).value
if ( ($currentTrustHost).Length -gt "0" ) {
$currentTrustHost+= ,$ServerList
set-item WSMan:\localhost\Client\TrustedHosts –value $currentTrustHost -Force -ErrorAction SilentlyContinue
}
else {
$currentTrustHost+= $ServerList
set-item WSMan:\localhost\Client\TrustedHosts –value $currentTrustHost -Force -ErrorAction SilentlyContinue
}
"-ErrorAction SilentlyContinue오래된 PS 버전에서는 가짜 오류 메시지를 피하기 위해 "가 필요합니다.
PS C:\Windows\system32> get-item WSMan:\localhost\Client\TrustedHosts
WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client
Type Name SourceOfValue Value
---- ---- ------------- -----
System.String TrustedHosts machineA,machineB,machineC,machineD
winrm set winrm/config/client '@{TrustedHosts="ServerA"}'
다음 오류를 생성합니다.
Syntax Error: input must be of the form {KEY="VALUE"[;KEY="VALUE"]}
이것은 나에게 효과가 있었다 (Server 2016):
winrm set winrm/config/client @{TrustedHosts="ServerA"}
언급URL : https://stackoverflow.com/questions/21548566/how-to-add-more-than-one-machine-to-the-trusted-hosts-list-using-winrm
'programing' 카테고리의 다른 글
| '치명적 오류:Optional value'의 래핑을 해제하는 동안 예기치 않게 0이 발견되었습니까? (0) | 2023.04.13 |
|---|---|
| UITextField 텍스트 변경 이벤트 (0) | 2023.04.13 |
| Excel 파일 생성 시 Column Width를 올바르게 설정하는 방법(Column 속성) (0) | 2023.04.13 |
| iOS 7+에서의 Base64 디코딩 (0) | 2023.04.13 |
| Excel - 조건부 형식 지정 - 행 삽입 (0) | 2023.04.13 |