I'm learning Powershell, I have this line at the top of example script, but it doesnt appear to be necessary. What does it do? Why would it be there?
# SharePoint DLL
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
For example this example script to get content types works if the above line is commented out.
# SharePoint DLL
# COMMENTED [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
#Cmdlet Install
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
# Get content types in a site collection.
# ----------------------------------------
function GetContentTypesInSite()
{
$site = new-object Microsoft.SharePoint.SPSite($SiteURL)
$web = $site.rootweb.ContentTypes
ForEach ($id in $web)
{
'"' + $id.Name + $id.Id + '"' | Out-File $OutputFile -append
}
}
$SiteURL = "http://server:33333"
$OutputFile = "C:\temp\contenttypes.txt"
GetContentTypesInSite
I'm using the Windows PowerShell ISE to run the scripts