Archives For PowerShell

SharePoint 2010 Cmdlet Listing


How to view name of the SharePoint sites which was created previous day?

$w= Get-SpWeb http://yoursite
$date=$w.created
$old=($date.AddDays(-1))
Get-SPSite -Filter {$w.Created -eq $old}

http://blogs.technet.com/b/heyscriptingguy/archive/2013/05/06/10-tips-for-the-sql-server-powershell-scripter.aspx


Creating one Content Database Per Site Collection In SharePoint 2010 using Windows PowerShell

One of the most common problems I see in a client built SharePoint environment is multiple site collections comingled in the same content database.  While this isn’t the end of the world, it’s a problem because SLAs, security, and even back strategies are often assigned to specific databases based upon the needs of the users that will be using the site collections hosted in each database.  If a site collection is not hosted in the database that the admin intended because SharePoint simply picks the first available content database with room  the administrator may unwittingly incorrectly back or, even worse, fail to backup a particular site collection because it does not exist in the proper database.  This is why I am a proponent of backing up at the Native SQL level but also at the site collection level.

On to the point of this article, how do I use PowerShell to create a site collection and assign the appropriate database

Here are the steps to how you can create Content Database Per Site Collection In SharePoint 2010 using Windows PowerShell


How do I download all the the prerequisites files for SharePoint 2010 installation?

Situation:
I need to install SharePoint 2010 in DMZ and the server is not having any access to internet.

Solution:
Downloaded all prerequisites for SharePoint 2010 in Windows 7 computer which is connected to internet and transferred to the server which I want to install SharePoint 2010

1. In Windows 7 I ran C:\Windows\System32\WindowsPowerShell\v1.0

Open powershell script editor in Windows 7

2. Open PowerShell folder and run powershell_ise.exe

Download SharePoint 2010 prerequisites

 

3. Download SharePoint 2010 prerequisites script  (copy and past it into powershell editor) and run the script

image

4. Enter the destination path for download SharePoint 2010 Prerequisite files and click OK

image

5. Downloading SharePoint 2010 Prerequisite files to the folder which we entered

Downloading SharePoint 2010 prerequisite in a folder


How to change SharePoint 2010 central admin port using Power Shell?
You can change the port central administration Port number using Power Shell command below

If your Central Administration Port number is 8080 and you want to change to 8081
Set-SPCentralAdministration –Port 8081


How to create a sub site using Power Shell scripts in SharePoint 2010?
To add a new subsite use the New-SPWeb cmdlet


New-SPWeb –url <new site url> -name <new site name> -template <template name>

Additional cmdlet which can be used:
AddToTopNav, UniquePermissions, UseParentTopNav

Sample Script to create new sub site in SharePoint using PowerShell

New-SPWeb –url http://vsharepoint/HyperV -name "All about HyperV"
-template STS#0 –AddToTopNav –UniquePermissions –UseParentTopNav

Template Names: http://virtualizesharepoint.com/2012/01/03/site-template-names-and-ids-in-sharepoint-2010/


How to create a top level site collection in SharePoint using PowerShell?
To add new site collection use the following cmdlets

New-SPSite –url <URL> -name <site collection name> -owneralias <site collection admin>
-template <template name>


Sample PowerShell to create new site collection in SharePoint 2010

New-SPSite –url http://virtualizesharepoint -name Home -owneralias vSharePoint\SpAdmin
-template STS#0

If you want to know the list of templates : http://virtualizesharepoint.com/2012/01/03/site-template-names-and-ids-in-sharepoint-2010/


How to find SharePoint 2010 site templates names and ID’s using PowerShell?
You can find site templates name and ID’s by running Get-SPWebTemplate | Sort-Object "Name"

Site Templates Names in SharePoint 2010

List of SharePoint 2010 Site Templates

RV#0
RV#0
RV#1
RV#1
RV#3
RV#3
RV#4
RV#4
RV#5
RV#5
RV#6
RV#6
0
0
nterSite#0
nterSite#0
KINTERNET#0
KINTERNET#0
KINTERNET#1
KINTERNET#1
KINTERNET#2
KINTERNET#2
KINTERNETCONT.
KINTERNETCONT.
#0
#0
RALADMIN#0
RALADMIN#0
UBLISHING#0
UBLISHING#0
RWIKI#0
RWIKI#0
AL#0
AL#0
0
0
1
1
2
2
3
3
4
4
LE#0
LE#0
LE#1
LE#1
#0
#0
rPointBroadca.
ASite#0
ASite#0
ILES#0
ILES#0
0
0
0
0
0
0
OMMU#0
OMMU#0
SITE#0
SITE#0
SITEHOST#0
SITEHOST#0
EWS#0
EWS#0
HOME#0
HOME#0
ERS#0
ERS#0
ORTAL#0
ORTAL#0
EPORTCENTER#0
EPORTCENTER#0
ITES#0
ITES#0
OC#0
OC#0
OPIC#0
OPIC#0
CEN#0
CEN#0
CENTERFAST#0
CENTERFAST#0
CENTERLITE#0
CENTERLITE#0
CENTERLITE#1
CENTERLITE#1
0
0
1
1
2
2
NTADMIN#0
NTADMIN#0
r#0
rus#0
#0
#0
Access Services Site
Site Access Services
Assets Web Database
Base de données Web – Biens
Charitable Contributions Web Database
Base de données Web – Dons
Base de données Web – Contacts
Contacts Web Database
Base de données Web – Projets
Projects Web Database
Issues Web Database
Base de données Web – Problèmes
Centre de documents
Document Center
Business Intelligence Center
Centre d’intelligence économique
Publishing Site
Site de publication
Site de communiqués de presse
Press Releases Site
Publishing Site with Workflow
Site de publication avec flux de travail
Portail de publication
Publishing Portal
Blog
Blog
Central Admin Site
Site de l’Administration centrale
Site de publication
Publishing Site
Enterprise Wiki
Wiki d’entreprise
Modèle global
Global template
Basic Meeting Workspace
Espace de travail Réunion – De base
Espace de travail Réunion – Vide
Blank Meeting Workspace
Decision Meeting Workspace
Espace de travail Réunion – Décision
Social Meeting Workspace
Espace de travail Réunion – Informel
Multipage Meeting Workspace
Espace de travail Réunion – Multipage
(obsolete) Records Center
(obsolète) Centre des enregistrements
Records Center
Centre des enregistrements
Shared Services Administration Site
Site d’administration des services pa…
Site de diffusion PowerPoint
PerformancePoint
PerformancePoint
Profils
Profiles
Site Project Web App
Site Microsoft Project
Site de travail de groupe
Group Work Site
SharePoint Portal Server Site
Site SharePoint Portal Server
Community area template
Modèle de zone Communauté
Personalization Site
Site de personnalisation
Hôte de sites Mon site
My Site Host
News Site
Site de News
Site de News
News Site
Espace personnel SharePoint Portal Se…
SharePoint Portal Server Personal Space
Portail de collaboration
Collaboration Portal
Centre de rapports
Report Center
Annuaire de sites
Site Directory
Contents area Template
Modèle de zone Sommaire
Modèle de zone Rubrique
Topic area template
Enterprise Search Center
Centre de recherche d’entreprise
FAST Search Center
Centre FAST Search
Centre de recherche de base
Basic Search Center
Basic Search Center
Centre de recherche de base
Site d’équipe
Team Site
Site vide
Blank Site
Espace de travail du document
Document Workspace
Site d’administration des clients
Tenant Admin Site
Référentiel de processus Visio
Visio Process Repository
Site Wiki
Wiki Site

To add new web application in SharePoint 2010 with PowerShell using New-SPWebApplication

New-SPWebApplication –applicationpool <Application pool name> -name <New App Name>
-applicationpoolaccount <service account> -port <Port Number>

Sample Command Line to create new Web Application in SharePoint 2010 using PowerShell

New-SPWebApplication –applicationpool SharePoint-80 -name SharePoint-80 
–applicationpoolaccount vSharePoint\SPAdmin -port 80


The SPModule.zip file is a sample Windows PowerShell module related to farm installation using Powershell
Download : SPModule Powershell


How to find out what version of Powershell do I have?

If you want to find out version of PowerShell, open your command prompt

1. Type in PowerShell to invoke PowerShell

2. Type in $host.version to find out the version of PowerShell which you have in your computer

 

Finding out PowerShell Version


Silverlight application allow you to visually assemble commands and you can use these commands for SharePoint 2010 and Office 365 administration purpose.
Great tools for those who want to create Power Shell scripts fast.

URL : http://www.microsoft.com/resources/TechNet/en-us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.html

Supported Products : SharePoint Foundation 2010, SharePoint Server 2010 and Office 365

Windows Power Shell Command Builder

Build your own Power Shell Scripts

Build Power Shell Scripts for SharePoint 2010


How I can view SharePoint 2010 template names using Power Shell?
which is the right SharePoint  2010 template to use for my farm?

To find out SharePoint 2010 template names

1. Open your SharePoint 2010 Management Shell
2. Type in Get-SPWebTemplate

SharePoint 2010 template

Name                 Title                                    LocaleId   Custom
----                 -----                                    --------   ------
GLOBAL#0             Global template                          1033       False
STS#0                Team Site                                1033       False
STS#1                Blank Site                               1033       False
STS#2                Document Workspace                       1033       False
MPS#0                Basic Meeting Workspace                  1033       False
MPS#1                Blank Meeting Workspace                  1033       False
MPS#2                Decision Meeting Workspace               1033       False
MPS#3                Social Meeting Workspace                 1033       False
MPS#4                Multipage Meeting Workspace              1033       False
CENTRALADMIN#0       Central Admin Site                       1033       False
WIKI#0               Wiki Site                                1033       False
BLOG#0               Blog                                     1033       False
SGS#0                Group Work Site                          1033       False
TENANTADMIN#0        Tenant Admin Site                        1033       False
ACCSRV#0             Access Services Site                     1033       False
ACCSRV#1             Assets Web Database                      1033       False
ACCSRV#3             Charitable Contributions Web Database    1033       False
ACCSRV#4             Contacts Web Database                    1033       False
ACCSRV#6             Issues Web Database                      1033       False
ACCSRV#5             Projects Web Database                    1033       False
BDR#0                Document Center                          1033       False
OFFILE#0             (obsolete) Records Center                1033       False
OFFILE#1             Records Center                           1033       False
OSRV#0               Shared Services Administration Site      1033       False
PPSMASite#0          PerformancePoint                         1033       False
BICenterSite#0       Business Intelligence Center             1033       False
SPS#0                SharePoint Portal Server Site            1033       False
SPSPERS#0            SharePoint Portal Server Personal Space  1033       False
SPSMSITE#0           Personalization Site                     1033       False
SPSTOC#0             Contents area Template                   1033       False
SPSTOPIC#0           Topic area template                      1033       False
SPSNEWS#0            News Site                                1033       False
CMSPUBLISHING#0      Publishing Site                          1033       False
BLANKINTERNET#0      Publishing Site                          1033       False
BLANKINTERNET#1      Press Releases Site                      1033       False
BLANKINTERNET#2      Publishing Site with Workflow            1033       False
SPSNHOME#0           News Site                                1033       False
SPSSITES#0           Site Directory                           1033       False
SPSCOMMU#0           Community area template                  1033       False
SPSREPORTCENTER#0    Report Center                            1033       False
SPSPORTAL#0          Collaboration Portal                     1033       False
SRCHCEN#0            Enterprise Search Center                 1033       False
PROFILES#0           Profiles                                 1033       False
BLANKINTERNETCONT... Publishing Portal                        1033       False
SPSMSITEHOST#0       My Site Host                             1033       False
ENTERWIKI#0          Enterprise Wiki                          1033       False
SRCHCENTERLITE#0     Basic Search Center                      1033       False
SRCHCENTERLITE#1     Basic Search Center                      1033       False
SRCHCENTERFAST#0     FAST Search Center                       1033       False
visprus#0            Visio Process Repository                 1033       False

 


How to change SharePoint 2010 Farm passphrase?

1. Open SharePoint 2010 Management Shell from Start, All Programs, Microsoft SharePoint 2010 Products.

2. Enter following cmdlet: Set-SPPassPhrase

Change SharePoint 2010 Passphrase

3. Type the new farm passphrase.

4. Confirm the passphrase.


How do I create a new power shell script in Windows 7 or run power shell script using Windows 7?
In Windows 7 comes with Power shell editor and power shell windows and the location is

C:\Windows\System32\WindowsPowerShell\v1.0

To open Power Shell window in Window 7 go to C:\Windows\System32\WindowsPowerShell\v1.0

Open PowerShell_ISE in Windows 7

If you want to create power shell script, open powershell_ise. 
Editing Power Shell script in Windows 7 using Powershell_ise.exe and if you want to run the scrip, just click F5

Editing Power Shell script in Windows 7 using Powershell_ise.exe

Running Powershell scripts in Windows 7 using Power Shell

Running Powershell scripts in Windows 7 using Power Shell