:원격 Windows 서버에 로컬 사용자 만들기 및 관리자 그룹에 추가를
$Computer = Read-Host "Computer name:"
$UserName = Read-Host "User name:"
$Password = Read-Host "Password" -AsSecureString
$AdminGroup = [ADSI]"WinNT://$Computer/Administrator,group"
$User = [ADSI]"WinNT://$Computer/$UserName,user"
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $UserName, (ConvertTo-SecureString $Password -AsPlainText –Force)
$User.SetPassword($Cred.GetNetworkCredential().Password)
$AdminGroup.Add($User.Path)
그리고 그것은 오류가 아래에 나와 있습니다 :
The following exception occurred while retrieving member "SetPassword": " The user name could not be found. At C:\test1.ps1:7 char:18 + $User.SetPassword <<<< ($Cred.GetNetworkCredential().Password) + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException + FullyQualifiedErrorId : CatchFromBaseGetMember The following exception occurred while retrieving member "Add": "The specified local group does not exist. At C:\test1.ps1:8 char:16 + $AdminGroup.Add <<<< ($User.Path) + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException + FullyQualifiedErrorId : CatchFromBaseGetMember
올바른 AdminGroup 이름을 얻으십시오! –
@Ansgar Wiechers - 고마워요. 사용자가 원격 작업에 추가했지만 위의 설정에도 불구하고 관리자 그룹에 추가되지 않습니다. –