Powershell

Sharepoint Powershell Quick Reference

################################################# ############### Jayaraja #################### ############### http://34.231.97.77 #################### ############## Bugs or Thoughts are welcome 🙂 sweetraskels@gmail.com #### ################################################ #Add Sharepoint Powershell Snap if its not loaded $powershellSnapin = “Microsoft.Sharepoint.Powershell” if ((Get-PSSnapin -Name $powershellSnapin -ErrorAction SilentlyContinue) -eq $null ) { Write-Host “———————————…

SharePoint Powershell command to verify if the Outgoing Email Functions in Sharepoint Environment

$site = New-Object Microsoft.SharePoint.SpSite(“http://atlasdev/eastern”) $web = $site.OpenWeb() $sent = [Microsoft.Sharepoint.Utilities.SpUtility]::SendEmail($web,0,0,”admin@34.231.97.77″,”Test mail subject”,”test mail body”) $sent Running this command will come back with either true or false. If its true then the email will be delivered. If its false then the…

Powershell script to create Link List in sharepoint

$addedSPSnapin = $false if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) { Add-PsSnapin Microsoft.SharePoint.PowerShell $addedSPSnapin = $true } try { $listTemplate = [Microsoft.SharePoint.SPListTemplateType]::Links $spweb.Lists.Add(“ListName”,”Desc of the List”,$listTemplate) write-host “List added in the Web : ” $spweb -foregroundcolor Green…

SharePoint Powershell to backup web.config with date time stamp

param( [string] $fileName) $location=$filename-replace “web.config$”,”” if (-not(Test-Path $fileName)) {break} “Original filename: $fileName” $fileObj = get-item $fileName $DateStamp = get-date -uformat “%Y-%m-%d@%H-%M-%S” $extOnly = $fileObj.extension if ($extOnly.length -eq 0) { $nameOnly = $fileObj.Name $con=”._copy” copy “$fileObj” “$fileObj$con” rename-item “$fileObj$con” “$location$nameOnly-$DateStamp” }…

SharePoint Powershell command to stop inheriting permission for sharepoint list and give custom permission

$visitorsSPGroupName = “GroupName” $spSite = New-Object Microsoft.SharePoint.SPSite(“Site Collection Url”) $web = $site.OpenWeb(“Web Application Name”) $list = $web.Lists[“List Name”] $visitorsSPGroup = $web.Groups[$visitorsSPGroupName] $list.BreakRoleInheritance($true) $assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($visitorsSPGroup) $assignment.RoleDefinitionBindings.Add(($web.RoleDefinitions | Where-Object { $_.Type -eq “Contributor” })) $list.RoleAssignments.Add($assignment) $list.Update() $web.Dispose() $spSite.Dispose() Note: this…

Bitnami