Showing posts with label Powershell. Show all posts
Showing posts with label Powershell. Show all posts

Thursday, March 18, 2021

18 Mar

How to list all sites and subsites in SharePoint Online using PowerShell?

function Get-SPOWebs(){param(   $Url = $(throw "Please provide a Site Collection Url"),   $Credential = $(throw "Please provide a Credentials"))  $context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)    $context.Credentials = $Credential   $web = $context.Web ...

Saturday, January 23, 2021

23 Jan

Last Modified date for site collection?

 Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Office.Server.Search.Query”)  [String]$lastDate = "1/1/2018"foreach($sc in $webapplication | Get-SPSite -Limit All){    Write-Host $sc.Url -ForegroundColor Yellow ...

Thursday, October 6, 2016

06 Oct

Cannot update Created By (Author) field through powershell

Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue $SPWeb = Get-SPWeb "http://sharepoint"; $SPList = $SPWeb.GetList("http://sharepoint/Lists/Favorites"); $userName = "i:0#.w|[domain]\[username]"; $user = Get-SPUser -web $SPWeb -Identity $userName; $SPListItem = $SPList.Items.Add(); $SPListItem["URL"] =...

Thursday, March 17, 2016

17 Mar

Export the Subsite moved to site Collection Using PowerShell

Export the subsite STSADM: stsadm -o export -url "http://sharepointsite/sites/order/" -filename D:\backup.cmp -includeusersecurity -versions 4 Powershell: Add-pssnapin microsoft.sharepoint.powershell Import-SPWeb -identity "http://sharepointsite/sites/order/"  -path D:\backup.cmp -includeusersecurity &nb...

Tuesday, March 15, 2016

15 Mar

How to get all default values for a document library

$FieldName = $list.Fields["NH Department"] Write-Output $("NH Department - Default Value " + $FieldName.DefaultValu...