Add Domain Groups to Local Groups

PowerShell script to add groups from trusted Domains to Local groups of a list of member servers.

 
 
 
 
 
3.8 Star
(6)
Add to favorites
Servers
4/28/2011
E-mail Twitter del.icio.us Digg Facebook
  • error "Add": "Unknown error (0x80005000)"
    1 Posts | Last post July 02, 2019
    • Hello,
      Running the script in Win10 (also 2012), it works fine as it is adding the group in the correct local group, however it keeps on returning (once) this below message:
      
      The following exception occurred while retrieving member "Add": "Unknown error (0x80005000)"
      At C:\temp\Add2LocalGroup.ps1:26 char:5
      +     ($LocalGroup).Add($DomainGroup.Path)
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
          + FullyQualifiedErrorId : CatchFromBaseGetMember
      
      I am running PS 4.0 and tested with 5.1 also.
      
      #Get List of Servers from Flat TXT file 
      $Servers = Get-Content WebServers.txt 
      #Initaliaze the Domain Group Object 
      $DomainGroup = [ADSI]"WinNT://DOMAIN/domain - group,group" 
       
      #Name the LogFile and Initialize it 
      $LogFile = ".\ServerLog.txt" 
      New-Item $LogFile -type file -force 
       
      ForEach ($Server in $Servers) #Loop through each server 
      { 
          $Server 
          $Server>>$LogFile 
       
          #Get Local Group object 
          $LocalGroup = [ADSI]"WinNT://$Server/Administrators,group" 
      
          #Assign DomainGroup to LocalGroup 
          $LocalGroup.Add($DomainGroup.Path)
      
          #Determine if command was successful 
          If (!$?) #Add failed 
          { 
              $Server + " fail: " + $Error[0]>>$LogFile 
              "">>$LogFile 
          } 
          Else #Add succeeded 
          { 
              $Server + " success">>$LogFile 
              "">>$LogFile 
              $Server + " success" 
          } 
      }
      
      I cannot figure out to what this message relates.
      Thanks for your help.
  • thanks
    1 Posts | Last post June 23, 2017
    • works on w10 too
  • thanks
    1 Posts | Last post May 15, 2017
  • Thanks
    1 Posts | Last post March 02, 2017
    • Worked fine for me on 200+ 2012 servers, thanks!
  • Thank you
    1 Posts | Last post December 02, 2015
    • Worked like a charm for me on several Windows 2008R2 servers.
      
      Thank :)