Monday, May 7, 2012

Get Root Organization using Powershell Script

Leave a Comment

To create this script, open notepad or any other text editor and save it as .ps1

To start with, we need to get reference of site through which we can get reference for ServiceContext

$site = Get-SPSite("site url")

$serviceContext = Get-SPServiceContext($site)

$opm = New-Object 

// Here Root organization can be referred by 2 ways either my passing ID as 1, because root organization ID is always 1.

$orgProfile = $opm.GetOrganizationProfile(1)

// Or it can be referred with RootOrganization Property

$orgProfile = $opm.RootOrganization

Write-Host $orgProfile.ID