Create an instance of object in powershell

14/11/2012 08:46

#in csharp it is: using Microsoft.SharePoint

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Sharepoint") 

 

#this represents: SPFieldUrlValue field = new SPFieldUrlValue(); in csharp

$field=new-object Microsoft.Sharepoint.SPFieldUrlValue
    $field.Url = "https://www.google.com"
    $field.Description="My favorite"

 

#object of Image Type
 $image = new-object Microsoft.SharePoint.Publishing.Fields.ImageFieldValue
 $image.ImageUrl = "https://server/sitecollection/publishingimages/image1.jpg"

 

#constructor with parameters

$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)