Monday, 24 April 2017


Add Solution
Add-SPSolution <literal path of wsp file>                                                                        
Deploy Solution
Install-SPSolution -Identity <solution_file (WSP Name)> -GACDeployment
Uninstall Solution
Uninstall-SPSolution –Identity "solution_file (WSP Name)".wsp –WebApplication "Site URL"
Update/Upgrade Solution
The Update-SPSolution cmdlet upgrades a deployed SharePoint solution in the farm. Use this cmdlet only if a new solution contains the same set of files and features as the deployed solution. If files and features are different, the solution must be retracted and redeployed by using the Uninstall-SPSolution and Install-SPSolution cmdlets, respectively
Update-SPSolution -Identity "solution_file (WSP Name)" -LiteralPath <literal path of wsp file> -GACDeployment
Install Feature
Install-SPFeature -path <literal path to the 15\Template\Features directory.> -CompatibilityLevel 15
Uninstall Feature
Uninstall-SPFeature -Identity <Feature Name>
Enable Feature
Enable-SPFeature -identity <Feature Guid> -URL "Site URL"
Get the list of features from site sorted by ID
get-spfeature -site "Site URL" | Sort Id
Get the list of features from site sorted by Name
get-spfeature -site "Site URL" | Sort Displayname
Get the list of features from site sorted by ID
get-spfeature -site "Site URL" | Sort Id
Get the list of features from site sorted by Name
get-spfeature -site "Site URL" | Sort Displayname
Take Site Backup
backup-spsite -identity <Site URL> -path "literal path to save backup file"
Restore Site Backup
Restore-SPSite -Identity <Site URL> -Path <literal path to save Backup file> [-DatabaseServer <Database server name>] [-DatabaseName <Content database name>] [-HostHeader <Host header>] [-Force] [-GradualDelete] [-Verbose]
Synchronise the AD User Data with User Profiles in SP Site
Get-SPUser –Web http://SharePointServer | Set-SPUser –SyncFromAD
Backing Up an Entire Web Application
backup-spfarm –BackupMethod Full –Directory C:\Backup\ -Item http://server
Backing Up the Farm Configuration
backup-spfarm –BackupMethod Full –Directory C:\Backup\ -ConfigurationOnly
Create a Web
New-SPWeb –URL "Web URL" -Verbose
Export a Web
export-spweb -identity "Web URL" -path "<literal path>\<backup file name>.cmp"
Import a Web
Import-SPWeb -Identity "Web URL" -Path "<literal path>\<backup file name>.cmp" -IncludeUserSecurity -UpdateVersions Overwrite
Export a List
export-spweb -identity "Web URL" -path "<literal path>\<backup file name>.cmp" -itemurl "/<listname>"
Import a List
Import-SPWeb -Identity "Web URL" -Path "<literal path>\<backup file name>.cmp" -IncludeUserSecurity -UpdateVersions Overwrite
Find List Name from Id
Get-SPSite "Site URL" | Get-SPWeb  -Limit ALL | %{$_.Lists} | ?{$_.ID –eq "<List ID>"} | ft Title, ParentWebURL, RootFolder
Assign User as Site Collection Administrator
Get-SPSite -Identity "Site URL" | %{Set-SPSite $_ -OwnerAlias "username" -SecondaryOwnerAlias "username"}
Get list of deployed solutions
$SPfarm = [Microsoft.SharePoint.Administration.SPFarm]::get_Local()
$SPfarm.get_Solutions()
Download the WSP that you have deployed in a SharePoint farm
$frm = Get-SPFarm
$file = $frm.Solutions.Item("Name of Solution i.e.WSP file name").SolutionFile
$file.SaveAs("literal path to save wsp file")
Get User Info
Get-SPUser -Web "Site URL" |  Where { $_.UserLogin -LIKE "*|domain\username" } |  Select ID, UserLogin, DisplayName
Get SharePoint Groups from Site Collection
Get-SPSite "Site URL" |  Select -ExpandProperty RootWeb | Select -ExpandProperty Groups |  Select {$_.ParentWeb.Url}, Name
Get All Users from SharePoint Group
Get-SPSite "Site URL" |  Select -ExpandProperty RootWeb |  Select -ExpandProperty Groups |  Where {$_.Name -EQ "<Group Name>"} |  Select -ExpandProperty Users |  Select Name, Email
Get SharePoint Groups of given user$user = Get-SPUser -Web "Site URL" |  Where {$_.LoginName -LIKE "*|domain\username"}
Get All Site Owners and All Site Collection Administrators
Get All Site Owners:
$web = Get-SPWeb "Site URL"
$web.AssociatedOwnerGroup.Users
Get  All Site Collection Administrators:
Get-SPSite -Limit All | Select Url, Owner, SecondaryContact

No comments:

Post a Comment