Showing posts with label PowerShell 2010. Show all posts
Showing posts with label PowerShell 2010. Show all posts

SharePoint 2010 Windows PowerShell Commands - II

Some more PowerShell Commands

Site Collection Commands

Create Site Collection :

Get-SPWebTemplate
$template = Get-SPWebTemplate "STS#0"
New-SPSite -Url "" -OwnerAlias "" -Template $template

Delete Site Collection :

Remove-SPSite -Identity "URL of site Collection" -GradualDelete

Change Site collection Quotas :

Set-SPSite -Identity "SiteCollection Url" -MaxSize Quota

Add site Collection Administrators :


Set-SPSite -Identity "" -SecondaryOwnerAlias ""

Lock or unlock a site collection :

Set-SPSite -Identity "Site Collection Url" -LockState ""

is one of the following vales :

# Unlock: To unlock the site collection and make it available to users.

# NoAdditions: To prevent users from adding new content to the site collection. Updates and deletions are still allowed.

# ReadOnly: To prevent users from adding, updating, or deleting content.

# NoAccess: To prevent access to content completely. Users who attempt to access the site receive an access-denied message.

Create a site :


New-SPSite "http://sitecollection/sites/Subsite -OwnerAlias "DOMAIN\UserName" –Language 1033

See more Commands @ SharePoint 2010 Windows PowerShell Commands - I

Windows Powershell Interview questions SharePoint 2010

Q. What is Windows Powershell ?

Ans. Windows PowerShell is a new Windows command-line shell designed especially for system administrators. In the SharePoint administration context, Windows PowerShell is another administration tool that supersedes the existing Stsadm.exe.


Q. How is Windows Powershell different from Stsadm ?

Ans. Unlike stsadm, which accept and return text, Windows PowerShell is built on the Microsoft .NET Framework and accepts and returns .NET Framework objects. In addition to that it also gives you access to the file system on the computer so that you can access registry,digital signature certificate etc..

Q. What are cmdlet's?

Ans. Windows PowerShell introduces the concept of a cmdlet which are simple build in commands, written in a .net language like C# or VB.

Q. Can you Create PowerShell scripts for deploying components in SharePoint ?

Ans. If you are creating a webpart with VS 2010 then you can deploy it using ctrl + f5. However, to activate the webpart feature you can write a powershell script (.ps1) and execute it after dpeloyment.


Q. Where is Powershell located in sharePoint ?

Ans. On the Start menu, click All Programs -> Click Microsoft SharePoint 2010 Products -> Click SharePoint 2010 Management Shell.


Q. If you need going to install a webpart or any custom solution in SharePoint 2010 using PowerShell What permissions do you need?

Ans. In order to use Windows PowerShell for SharePoint 2010 Products, a user must be a member of the SharePoint_Shell_Access role on the configuration and content database. In addition to this, the user must also be a member of the WSS_ADMIN_WPG local group on the computer where SharePoint 2010 Products is installed. See Details
Permissions for Windows PowerShell - SPShellAdmin


Q. How to list all the commands in PowerShell ?

Ans. Get-Command * commands gets you all the Powershell commands. For more commands see Here

Related Post : SharePoint 2010 Interview Questions for administrators

Permissions for Windows PowerShell - SPShellAdmin

In order to use Windows PowerShell for SharePoint 2010 Products, a user must be a member of the SharePoint_Shell_Access role on the configuration and content database. In addition to this, the user must also be a member of the WSS_ADMIN_WPG local group on the computer where SharePoint 2010 Products is installed.

To add a user as SharePoint_Shell_Access on the SharePoint database use the below powershell cmdlet :

Add-SPShellAdmin

Please Note that to run the above cmdlet you must have
* Membership in the securityadmin fixed server role on the SQL Server instance
* Membership in the db_owner fixed database role on all affected databases
* and local administrative permission on the local computer.

In addition to above some important things to Note:

* The user gets added to the WSS_Admin_WPG group on all Web servers when the user is added to the SharePoint_Shell_Access role.

* If the target database does not have a SharePoint_Shell_Access role, the role is automatically created.

* If you use the database parameter, the user is added to the role on the farm configuration database, the Central Administration content database, and the specified database. Using the database parameter is the preferred method because most of the administrative operations require access to the Central Administration content database. The cmdlet is something like below :

Add-SPShellAdmin -UserName Domainname\User -database {Database GUID}

Windows PowerShell in SharePoint 2010 - Tutorial II

Now lets talk about Powershell Commands. Firstly, steps to open up the PoweShell:

On the Start menu, click All Programs.

Click Microsoft SharePoint 2010 Products.

Click SharePoint 2010 Management Shell.

At the Windows PowerShell command prompt (PS C:\>), type the following command, and then press ENTER:

Note : You must be a member of the SharePoint_Shell_Access role on the configuration database and a member of the WSS_ADMIN_WPG local group on the computer where SharePoint 2010 Products is installed. For more info see my post Permissions for Powershell

The Windows PowerShell Get-Command cmdlet gets all commands in the current session.

Command is : Get-Command *

The output for this command looks a lot like the Help output of Cmd.exe. Its basically a tabular summary of all the internal commands along with the CommandTypes.

However, if you want to display Syntax of one command you can use the below command.
For e.g. to get syntax for Get-SPFeature cmdlet use ...

Get-Command Get-SPFeature -Syntax

Note : The Get-Command command does not list every command that is available in Windows PowerShell. Instead, the Get-Command command lists only the cmdlets in the current session.

To get all the Alias (The commands which are assigned nicknames) Use -
Get-Command -CommandType Alias

To get all the functions in the current session Use -
Get-Command -CommandType Function

To display scripts in Windows PowerShell's search path Use -
Get-Command -CommandType Script

For more Commands see : Common PowerShell Commands

Related Post :

What is Windows PowerShell in SharePoint 2010 - Tutorial- I

Windows Powershell Resources

What is Windows PowerShell in SharePoint 2010 - Tutorial

What is Windows Powershell - Windows PowerShell is a new Windows command-line shell designed especially for system administrators. The Windows PowerShell includes an interactive prompt and a scripting environment that can be used independently or in combination.

Unlike most shells, which accept and return text, Windows PowerShell is built on top of the .NET Framework common language runtime (CLR) and the .NET Framework, and accepts and returns .NET Framework objects. This fundamental change in the environment brings entirely new tools and methods to the management and configuration of Windows.

What are cmdlet's - Windows PowerShell introduces the concept of a cmdlet (pronounced "command-let"), a simple, build in commands, written in a .net language like C# or VB. Users can extend the set of cmdlets by writing and loading powershell snap-ins. Windows PowerShell includes more than one hundred basic core cmdlets, and you can write your own cmdlets and share them with other users.

Like many shells, Windows PowerShell gives you access to the file system on the computer. In addition, Windows PowerShell providers enable you to access other data stores, such as the registry and the digital signature certificate stores, as easily as you access the file system.

Scripts – Scripts are text files on disk with a .ps1 extension containing a collection of powershell commands.

Functions – are commands written in powershell languages that are defined dynamically. Funcations can be accessed using name-space qualified as in $fucntion:prompt.

Variables - In powershell, variables are organized into namespaces, variables are identified in a script by prefixing their names with a “$” sign in “$x=3” or by name-space qualifies like: $variable:x.

See : What is Windows PowerShell in SharePoint 2010 - Tutorial II

Permissions for Windows Powershell

Windows PowerShell for SharePoint 2010 Resources

Listed are some import resources for PowerShell 2010

Introduction :

Technet - Windows PowerShell is a command-line scripting tool that provides an administrator full access to applicable application programming interfaces (APIs), along with the ability to unlock the capability to interact directly with SharePoint 2010 Products to manipulate Web applications, site collections, sites, lists and much more. In addition, the administrator has the ability to script cmdlets (pronounced “command-lets”), which makes for an improved experience in administering SharePoint 2010 Products.
Read More.. SharePoint 2010 Products administration

SharePoint Monitor - Windows PowerShell is a task-based command-line shell and scripting language designed especially for system administration. Built on the .NET Framework, Windows PowerShell™ helps IT professionals and power users control and automate the administration of the Windows operating system and applications that run on Windows.
Read More...Getting Started with PowerShell for SharePoint

Windows PowerShell Owner's Manua


Windows PowerShell Quick Reference

Commands :

SharePoint Programming - See my post for Common PowerShell Commands
SharePoint 2010 Windows PowerShell Commands

To Install WebPart Soultion Package and Installing, Activating and Deactivating Fetaures see: Deploy SharePoint 2010 Web Parts Using windows PowerShell

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer or anyone else. Should you have any questions or concerns please e-mail me at sharepointprogrammingblogger@gmail.com .

Copyright (c) 2010 @ myshaepointwork.blogspot.com. All rights are reserved.Do Not Copy.

@ Learning SharePoint.com