If you would like to update Active Directory User/Group profile information in a SharePoint 2007 site, you can use below commands to achieve this.
[Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=Neutral, PublicKeyToken=71e9bce111e9429c")
$site = New-Object -TypeName Microsoft.SharePoint.SPSite -ArgumentList http://sharePointsiteurl
$group = $site.RootWeb.SiteUsers["Domain\grouploginname"]
$group.Name = "Group Name"
$group.Email = "groupemail@test.com"
$group.Update()
Important Note: SID should match in both Active Directory and SharePoint for the user/group, otherwise the above steps will not work.
To check the SID of a group from Active Directory
Command: wmic useraccount where name='grouploginname' get sid
[Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=Neutral, PublicKeyToken=71e9bce111e9429c")
$site = New-Object -TypeName Microsoft.SharePoint.SPSite -ArgumentList http://sharePointsiteurl
$group = $site.RootWeb.SiteUsers["Domain\grouploginname"]
$group.Name = "Group Name"
$group.Email = "groupemail@test.com"
$group.Update()
Important Note: SID should match in both Active Directory and SharePoint for the user/group, otherwise the above steps will not work.
To check the SID of a group from Active Directory
Command: wmic useraccount where name='grouploginname' get sid
No comments:
Post a Comment