Site Collection Backup
Backup-SPSite -Identity <Site collection name> -Path <backup file> [-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]
Site Collection Restore
Restore-SPSite -Identity <Site collection URL> -Path< Backup file> [-DatabaseServer <Database server name>] [-DatabaseName <Content database name>] [-HostHeader <Host header>] [-Force] [-GradualDelete] [-Verbose]
Export Site
Export-SPWeb -Identity <Site URL> -Path <Path and file name> [-ItemUrl <URL of site, list, or library>] [-IncludeUserSecurity] [-IncludeVersions] [-NoFileCompression] [-GradualDelete] [-Verbose]
Import Site
Import-SPWeb -Identity <Site URL> -Path <Export file name> [-Force] [- NoFileCompression] [-Verbose]
Get all site details
$a = Get-SPWebApplication "<<SiteCollectionName" | Get-SPSite -Limit All
$a | Select RootWeb, Url, Owner > c:\emea.csv
$a | Select RootWeb, Url, Owner | Format-Table -AutoSize >data.csv
Deploy BDC from PowerShell
$metaStore = Get-SPBusinessDataCatalogMetadataObject -BdcObjectType "Catalog" -ServiceContext <<SiteCollectionName"
Import-SPBusinessDataCatalogModel -Path "D:\Droppoint\test.bdcm" -Identity $metaStore -Force
Get Database names of sites
Import-SPBusinessDataCatalogModel -Path "D:\Droppoint\test.bdcm" -Identity $metaStore -Force
Get Database names of sites
Get-SPContentDatabase | %{Write-Output "- $($_.Name)”; foreach($site in $_.sites){write-Output $site.url}} > C:\sitecollections.txt
Site Collection Sizes
Site Collection Sizes
Get-SPSite -Limit ALL | select url, ContentDatabase, Owner, @{label="Size in MB";Expression={$_.usage.storage/1MB}} | Sort-Object -Descending -Property "Size in MB" | Format-Table –AutoSize | Out-String -Width 100000 > D:\CollectionSize.txt
Get all Sub Site names
$web | Select-Object -Property Title,Url,WebTemplate
}
$site.Dispose()
Search for Correlation ID in ULS logs
$term= '<CoorelationID>'
Select-String -pattern "$term" -Path E:\SPLogs\ULS\*.* -list
Mount and Unmount the DB
Dismount-SPContentDatabase "<DBNAME>"
Mount-SPContentDatabase "<DBNAme>" -DatabaseServer "<ServerName>" -WebApplication http://mysitename
Site Collections and its DB names
Get-SPContentDatabase | %{Write-Output "- $($_.Name)”; foreach($site in $_.sites){write-Output $site.url}}
Get Servers in Farm
Get-SPServer
Get All Application Servers in Farm
get-spserver | ? { $_.Role -eq "Application" }
Content Database Size
Get-SPDatabase | select name, disksizerequired| Sort-Object disksizerequired -desc| Format-Table –AutoSize > c:\contDBSize.csv
Storage Details of Site Collection
Get-SPSite -Limit 5| Select URL, @{Name=”Storage”; Expression={“{0:N2} MB” -f ($_.Usage.Storage/1000000)}}, @{Name=”Quota”; Expression={“{0:N2} MP” -f ($_.Quota.StorageMaximumLevel/1000000)} } | Format-Table –AutoSize | Out-string -width 10000 > C:\output.csv
To avoid truncation of PowerShell output: $FormatEnumerationLimit =-1
Site Owners
Get-SPWebApplication <WebAppName> | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, ID, ParentWebID,@{Name=’SiteAdministrators’;Expression={[string]::join(";", ($_.SiteAdministrators))}} | Export-CSV C:\InfoArch.csv -NoTypeInformation
Orphaned Database
$orphanedDB = Get-SPDatabase | where{$_.Name -eq "MyContentDatabase"}
$orphanedDB.Delete()
No comments:
Post a Comment