Sharepoint

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