## SharePoint DLL
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Policy")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Portal")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration")
############################################
# Get-SPSite -url
############################################
function global:Get-SPSite($url){
return new-Object Microsoft.SharePoint.SPSite($url)
}
############################################
# Get-SPWeb [-url | -site ]
############################################
function global:Get-SPWeb($url,$site)
{
if($site -ne $null -and $url -ne $null){"Url OR Site can be given"; return}
#if SPSite is not given, we have to get it...
if($site -eq $null){
$site = Get-SPSite($url);
}
#Output 1 or more sites...
if($url -eq $null){
for($i=0; $i -lt $s.AllWebs.Count;$i++){
Write-Output $s.AllWebs[$i]; ##Send through Pipeline
$s.Dispose(); ##ENFORCED DISPOSAL!!!
}
}else{
Write-Output $site.OpenWeb()
}
}
############################################
# Dispose-SPWeb -web -parent
############################################
function global:Dispose-SPWeb($web,$parent=$false){
$site = $web.Site;
$web.Dispose();
if($parent){ $site.Dispose(); }
}
############################################
# Get-SPFarm
############################################
function global:Get-SPFarm(){
return [Microsoft.SharePoint.Administration.SPFarm]::Local
}
############################################
# Get-SPWebApp -url
############################################
function global:Get-SPWebApp($url){
return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($url)
}
[...] SharePoint site column using PowerShell This code requires the SharePoint Powershell Profile to be loaded beforehand… [...]
Pingback by Create SharePoint site column using PowerShell « SharePoint Tech Blog — 05/08/2009 @ 3:40 am
[...] List/Enumerate information management policies on a SharePoint site collection This code requires the SharePoint Profile for PowerShell [...]
Pingback by List/Enumerate information management policies on a SharePoint site collection « SharePoint Tech Blog — 05/08/2009 @ 5:41 am
[...] be set using stsadm. Instead, use this Powershell script to run it manually: This code requires the SharePoint Powershell Profile to be loaded beforehand… $farm=[Microsoft.SharePoint.Administration.SPFarm]::Local foreach [...]
Pingback by Execute SharePoint timer job using Powershell « SharePoint Tech Blog — 10/08/2009 @ 4:26 am
[...] code requires the SharePoint Powershell Profile to be loaded beforehand $web=Get-SPWeb -url "http://moss/sitedirectory"; [...]
Pingback by Add item to SharePoint list and approve using Powershell « SharePoint Tech Blog — 11/08/2009 @ 7:31 am
[...] site directory, it could be modified to read any other list in SharePoint. This code requires the SharePoint Powershell Profile to be loaded beforehand $web=Get-SPWeb -url "http://moss/sitedirectory"; [...]
Pingback by Read SharePoint list using PowerShell « SharePoint Tech Blog — 11/08/2009 @ 10:52 pm
[...] one of the out of the box Disposition Approval workflows to a list. This code requires the SharePoint Powershell Profile to be loaded [...]
Pingback by Associate a workflow to a SharePoint list « SharePoint Tech Blog — 14/08/2009 @ 1:56 am
[...] one of the out of the box Disposition Approval workflows to a list. This code requires the SharePoint Powershell Profile to be loaded [...]
Pingback by Associate a workflow to a SharePoint list using Powershell « SharePoint Tech Blog — 14/08/2009 @ 1:57 am
[...] could be used to set the expiry policy programmatically using PowerShell. This code requires the SharePoint Powershell Profile to be loaded [...]
Pingback by Set expiry policy on SharePoint list using Powershell « SharePoint Tech Blog — 15/08/2009 @ 1:55 pm
[...] I find this a bit easier to use since it uses an xml file as its input. This code requires the SharePoint Powershell Profile to be loaded. [...]
Pingback by Create SharePoint Audiences using Powershell « SharePoint Tech Blog — 03/05/2010 @ 12:49 am
[...] — Tags: Powershell, SharePoint — kctnpblog @ 8:42 pm This code requires the SharePoint Powershell Profile to be [...]
Pingback by Enumerate SharePoint features using Powershell « SharePoint Tech Blog — 29/07/2010 @ 8:42 pm