So today, I started studying how to work with PowerShell scripting for SharePoint, and it seems to be pretty easy and cool :)
The first thing you must do so PowerShell can access SharePoint assemblies is to load them using below code line:
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
Once you have the assemblies loaded, you can invoke all methods of SP object model, just like if you were developing with any .NET programming language. Below example shows how to get both the primary and secondary Site Collection Administrators from a given URL:
$site = New-Object Microsoft.SharePoint.SPSite("http://mysite")
$priSCALogin = $site.Owner.LoginName
$secSCALogin = $site.SecondaryContact.LoginName
write "-Primary SCA: $priSCALogin"
write "-Secondary SCA: $secSCALogin"
I'll keep working and studying about this and obviously, posting.
I'll keep working and studying about this and obviously, posting.
No comments:
Post a Comment