0

Just like the entire MSDN API for the SharePoint server side object model is available with classes, objects,methods and samples https://msdn.microsoft.com/en-us/library/office/jj162979.aspx?f=255&MSPPError=-2147217396

Similar this, Can i get the API methods, classes for PowerShell with SPSite, SPWeb, SPGroup,SPList, SPDocumentLibrary objects and its associated methods? Is there any msdn site exists, can anyone post the link here?

  • Want to make this as a community question *** . But am unable to see the community checkbox. pls help – SaMolPP Mar 16 '17 at 16:23
2

Microsoft publishes Use Windows PowerShell to administer SharePoint 2013 which is the reference for SharePoint cmdlets. That said, the SSOM API is identical, should you need to create new objects manually. For example, here's a PowerShell script that mixes native cmdlets and the SSOM API directly.

$site = (Get-SPWebApplication -IncludeCentralAdministration | ?{$_.IsAdministrationWebApplication -eq $true}).Sites[0]
$context = Get-SPServiceContext $site
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$profiles = $upm.GetEnumerator()

And as another example, here's one that performs reflection (reflection is not supported by the SharePoint PG) using PowerShell.

$upa = Get-SPServiceApplication | where {$_.Name -eq "User Profile Service Application"}

$propData = $upa.GetType().GetProperties([System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic)

$socialProp = $propData | where {$_.Name -eq "SocialDatabase"}
$socialProp.GetValue($upa)

$profileProp = $propData | where {$_.Name -eq "ProfileDatabase"}
$profileProp.GetValue($upa)

$syncProp = $propData | where {$_.Name -eq "SynchronizationData"}
$syncProp.GetValue($upa)
  • Trevor, I have a requirement to fetch a speicif property of a SPGroup and set that property accordingly.since he num of groups are huge, i cant do that change manually so i thought of writing the powershell script. but i am unable to get the property of that spgroup object. like" who can view the membership of the group" . i have written the C# + SSOM , for implementing this, but when i thought of doing this using powershell , am not knowing, what will be the properties of this spobject. in my powershll ISE , there is no intellisense , so i cant assume as well. thats the issue. – SaMolPP Mar 16 '17 at 16:31
  • 1
    The properties are the same on the objects. For PowerShell, you would get the specific SPSite.RootWeb.SiteGroups object you want, then just example the OnlyAllowMembersViewMembership property. If it is false, then everyone who has access to the site can see the membership of the group. – Trevor Seward Mar 16 '17 at 16:34
  • your suggestion and valuable PS code helped me to write the script. :-) – SaMolPP Mar 16 '17 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.