Grab our RSS feeds Follow us on Twitter Join our Facebook Group Connect with us on LinkedIn
myITforum.com, Powered by You.
you are not logged in

Articles

Newslinks

Links

Downloads

Site Services

Community Forums

Discussion Lists

Article Search

Newsletter

Web Blogs

FAQs

Live Support

myITforum TV

Take a Poll

Monthly Drawing

myITforum Network

User Group Directory

Our Partners

About Us

Register

Login

BRONZE PARTNER:

BRONZE PARTNER:



Industry News:




  Home : Articles : Active Directory and Group Policy print | email | | Forums |   print | email | | Blogs |   print | email | | Wiki |   print | email | | FAQs |   print | email | Article Search  
Copying Active Directory Group Membership For Software Distribution – Powershell


Bookmark and Share

By: Chris Nackers
Posted On: 1/12/2010

Through SMS/SCCM we use AD groups for software distribution. Something that happens often enough is that we need to copy the groups that one computer is a member of to another computer. Thanks to help from David Crown, I have a nifty powershell script that will do that for me now. If you just run the script straight, it will prompt for the source computer and the destination computer. Otherwise you call the powershell straight with the parameters “Script -src source_comptuer -dest destination_computer”

Also have a simple vbscript to call it for you so you don’t have to open a powershell prompt every time you want to run it.

Details below, and files attached to this post.

You will just need to change the “PATH” in the vbscript file to where the script is stored:

Set objShell = CreateObject("Wscript.Shell")
objShell.Run("powershell.exe –noexit &'PATH\copygroupmembership.ps1'")

Here is the powershell script:

Param ($src, $dest)

Add-PSSnapin Quest.ActiveRoles.ADManagement

if ( ($dest -eq $null) -or ($src -eq $null) ) {

[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')

$src = [Microsoft.VisualBasic.Interaction]::InputBox("Enter the name of the source computer", "Source Computer")

$dest = [Microsoft.VisualBasic.Interaction]::InputBox("Enter the name of the destination computer", "Destinaton Computer")

}
$dest = $dest +"$"

$src = $src + "$"

$Groups = get-QADMemberOf $src

$Groups | foreach {
if ($_.name -ne "Domain Computers") {

Add-QADGroupMember $_ -Member $dest

}

}

Download Script: Copygroupmembership.zip

  myITforum.com ©2010 | Legal | Privacy