PowerShell Operations SharePoint Command set

Source: Internet
Author: User

Open the SharePoint Management Shell, and then run as Administrator. Execute the following command

1. Adding WSP and Installation
Add-spsolution-literalpath "C:\DEPLOYRESOURCE\WSP\TEST.WSP"
Install-spsolution-identity "test.wsp"-webapplication "http://domain:port/"-gacdeployment-force

Remove-webapplication "http://domain:port/" if it is a resource-free installation

2. Update wsp: update-spsolution-identity splistupdatead.wsp-literalpath "D:\BackupOfBackup\Release_20141010\ WSP\SPLISTUPDATEAD.WSP "-gacdeployment

3. backup wsp: get-spsolution | Where {$_. Name-eq "SPLISTUPDATEAD.WSP"} | foreach-object{$_. Solutionfile.saveas ("D:\Backwsp\" +$_. Name)}

4. To remove the WSP, you need to solution>retract the WSP in Ca>system Settings>farm before executing the PowerShell script below
Remove-spsolution-identity "HKEXSITEWAKEUPTIMERJOB.WSP"-confirm: $false

5. Remove the timer job

$job = Get-sptimerjob-id 3219759c-c748-444c-9ed7-bb3afb17fc9f
$job. Delete ()

6. Query the timer job
Get-sptimerjob | where {$_.name-like "*hkex*"} |ft Id,name

7. Activating feature
Enable-spfeature-identity "Sharepointwebpartproject_sharepointwebpartfeature"-url http://www.contoso.com
8. Disable feature
Disable-spfeature-id 1563deb1-0c37-481c-9463-f3581e720897-url Http://www.contoso.com-Url http://www.contoso.com

Windows PowerShell is a command-line scripting tool that allows administrators full access to the applicable application programming interface (API), and features that interact directly with SharePoint 2010 products to manipulate Web applications, site collections, sites, lists, and more. Ability to unlock the lock. In addition, an administrator can write a script for the cmdlet (pronounced "command-let") to improve the experience of previous product versions.

Windows PowerShell 2.0 is the prerequisite software for installing SharePoint 2010 products. If necessary, you will install it when you run the Microsoft SharePoint products Preparation tool. By default, Windows PowerShell is located in the following path: <%systemroot%>/system32/windowspowershell/v1.0/powershell.exe.

Access Windows PowerShell for SharePoint 2010 Products

When you finish installing SharePoint 2010 products, the applicable Windows PowerShell cmdlets are accessible through the SharePoint Management Shell or the Windows PowerShell console. From the shell, you can manage all aspects of SharePoint 2010 products. You can create new site collections, Web applications, user accounts, service applications, proxies, and so on. commands from the shell will output SharePoint objects based on the Microsoft. NET platform. These objects can be used as input objects for subsequent commands, or stored in local variables for later use.

Using the shell, you do not have to register a snap-in that contains cmdlets. Registering the Microsoft.SharePoint.PowerShell.dll module that applies to the SharePoint all cmdlet is done automatically by the %commonprogramfiles%/ In the Sharepoint.ps1 file under Microsoft shared/web Server extensions/14/config/powershell/registration Add-pssnapin Microsoft.SharePoint.PowerShell line execution. If you choose to use the Windows PowerShell console, you must manually register the snap-in.

$ver = $host | Select version
if ($ver. Version.major-gt 1) {$Host. runspace.threadoptions = "Reusethread"}
Add-pssnapin Microsoft.SharePoint.PowerShell
Set-location $home

The above command registers administrative commands for SharePoint in Windows PowerShell.

SharePoint Command

With more than 500 commands in the SharePoint PowerShell snap-in, you can use it to accomplish many administrative tasks. We can get to the list of commands through Get-command. Single Get-command gets to be all the underlying commands for Windows PowerShell, such as: Features, aliases, filters, scripts and applications. The command that starts with the letter for the SP in all commands is the one that is applied by SharePoint. If you want to know what SharePoint commands have, we can get to them by following the commands below.

PS > Get-command-noun sp*

The command information obtained by using the command is indicated in.

If you use a command such as sp* to get the information, very much. We can refine our commands in the following. For example, using SPSite

PS > Get-command-noun SPSite

Get the results:

Use SharePoint PowerShell Command

Let's take a look at how the Get-spsite command is used, try using this command in SharePoint PowerShell, and see the information returned by the command.

PS > Get-spsite
Url
---
Http://spservername

This command returns the URL of all site collections, but what if we need to know more about a single site collection?

We can use the select-object command to display additional attribute information. For example: We can use –identity to specify the name of a site collection, and then use select-object to get some information about this site collection

PS > Get-spsite-identity http://localhost | Select-object-property Url, Zone, Port

Of course, I can also change some specific properties of a site collection by command, first of all let's learn how to use the set-spsite command to add a second administrator of a site collection to a site set.

PS > Get-spsite-identity http://SPServer | Set-spsite-secondaryowneralias Domain/user

If we use the select-object command again, it will be possible to secondarycontact this attribute information. Let's take this command to see the name of the second administrator you just added.

PS > Get-spsite-identity http://localhost | Select-objec Secondarycontact

You can save SPSite as an object in a variable, for example:

PS > $spSite = get-spsite-identity http://SPServer

So that we can add its second administrator to this variable, we can also pass Microsoft.SharePoint.SPUser to return a site to the existing user to do as the site collection of the second administrator, we can use the command:

PS > $spSite = get-spsite-identity http://SPServer
PS > $spSite. secondarycontact = (get-spuser-web http://SPServer-Identity domain/user)

If we need to add a user in AD, but not a user in the site collection, become the second administrator of the site collections. We need to add a user to the site collection with the new-spuser command First, and then add it as a second site administrator using the command.

PS > $spUser = New-spuser-web http://SPServer-UserAlias domain/newuser
PS > $spSite. secondarycontact = $spUser

When we initialize an object in PowerShell, we must use the Dispose () method to free up this memory space.

PS > $spSite. Dispose ()

Why do we use the Dispose () command? Because, like SPWeb,SPSite,spsiteadministration objects can consume a lot of memory resources when they are used, So we use the PowerShell command to effectively reduce the memory footprint. In general, we initialize an object by using the command get-spsite , which releases the resource automatically after the call is finished. However, this does not save the object in a variable. When initializing an object, we can use the Dispose () method to free up memory, or you can use start-spassignment and stop- Spassignment command to create and release storage areas. We can use the get-help start-spassignment or get-help stop-spassignment command in PowerShell to view its descriptive information and how it is used.

PowerShell Operations SharePoint Command set

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.