if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) { Add-PSSnapin Microsoft.SharePoint.PowerShell; } $sourceWebURL = "http://sezmnc22787" $sourceListName = "DL_Accounts" $spSourceWeb = Get-SPWeb $sourceWebURL $spSourceList = $spSourceWeb.Lists[$sourceListName] If(!($spSourceList -eq $null)){ $spSourceItems = $spSourceList.GetItems() $spSourceItems | ForEach-Object { $Username=$_['AccountName'] $Username=$Username.Substring($Username.IndexOf("#")+1) $Group = [ADSI]"LDAP://CN=CMIT, CN=Users, DC=env, DC=com" $User = [ADSI]"LDAP://CN=$Username, CN=Users, DC=env, DC=com" If ($Group.IsMember($User.ADsPath) -eq $False) { $Group.Add($User.ADsPath) } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)