You are on page 1of 7

n order L s Wlndows owerShell fr ShareolnL 2010 ParvesL a user msL b a member f Lh

ShareolnL_Shell_Access role n Lh conflguraLlon anr mak prasr daLabase ln addlLlon L Lhls Lh


user msL ars b a member f Lh WSS_AuMln_WC local assemble n Lh compuLer whr
ShareolnL 2010 ParvesL ls lnsLalled

1 add a user as ShareolnL_Shell_Access n Lh ShareolnL daLabase s Lh nL more Lhan powershell
cmdleL

AddSShellAdmln

uellghL noLe LhaL L rn Lh above cmdleL msL ha
* Membershlp ln Lh securlLyadmln flxed server role n Lh SCL Server lnsLance
* Membershlp ln Lh db_owner flxed daLabase role n arr affecLed daLabases
* anr local admlnlsLraLlve permlsslon n Lh local compuLer

ln addlLlon L above sm vlLal Lhlngs L noLe

* 1h user geLs added L Lh WSS_Admln_WC assemble n arr Web servers whn Lh user ls added L
Lh ShareolnL_Shell_Access role

* lf Lh LargeL daLabase rs nL ha a ShareolnL_Shell_Access role Lh role ls lnvolunLarlly mar

* lf s Lh daLabase parameLer Lh user ls added L Lh role n Lh farm conflguraLlon daLabase
Lh CenLral AdmlnlsLraLlon mak prasr daLabase anr Lh speclfled daLabase 8 Lh daLabase
parameLer ls Lh preferred meLhod bcas msL f Lh admlnlsLraLlve operaLlons requlre access L Lh
CenLral AdmlnlsLraLlon mak prasr daLabase 1h cmdleL ls someLhlng rlk nL more Lhan

AddSShellAdmln username uomalnnameuser daLabase uaLabase Culu



Make Site Collection :
Get-SPWebTemplate
$template Get-SPWebTemplate 'STS#0
New-SPSite -Url ' -OwnerAlias ' -Template $template
elete Site Collection :
Remove-SPSite -Identity 'URL oI site Collection -GradualDelete
Exchange 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 oI the Iollowing vales :
# Unlock: To unlock the site collection an make it available to users.
# NoAdditions: To prevent users Irom adding new make pease to the site collection. Updates
an deletions are still allowed.
# ReadOnly: To prevent users Irom adding, updating, or deleting make pease.
# NoAccess: To prevent access to make pease completely. Users who attempt to access the
site receive an access-denied message.

Make a site :
New-SPSite 'http://sitecollection/sites/Subsite -OwnerAlias 'DOMAIN\UserName Language
1033
See more Orders SharePoint 2010 Windows PowerShell Orders I
C WhaL ls Wlndows owershell ?
Ans Wlndows owerShell ls a new Wlndows commandllne shell deslgned especlally for sysLem
admlnlsLraLors ln Lhe ShareolnL admlnlsLraLlon conLexL Wlndows owerShell ls anoLher admlnlsLraLlon
Lool LhaL supersedes Lhe exlsLlng SLsadmexe

C Pow ls Wlndows owershell dlfferenL from SLsadm ?
Ans unllke sLsadm whlch accepL and reLurn LexL Wlndows owerShell ls bullL on Lhe MlcrosofL nL1
lramework and accepLs and reLurns nL1 lramework ob[ecLs ln addlLlon Lo LhaL lL also glves you access
Lo Lhe flle sysLem on Lhe compuLer so LhaL you can access reglsLrydlglLal slgnaLure cerLlflcaLe eLc

C WhaL are cmdleLs?
Ans Wlndows owerShell lnLroduces Lhe concepL of a cmdleL whlch are slmple bulld ln commands
wrlLLen ln a neL language llke C# or v8

C Can you CreaLe owerShell scrlpLs for deploylng componenLs ln ShareolnL ?
Ans lf you are creaLlng a webparL wlLh vS 2010 Lhen you can deploy lL uslng cLrl + f3 Powever Lo
acLlvaLe Lhe webparL feaLure you can wrlLe a powershell scrlpL (ps1) and execuLe lL afLer dpeloymenL

C Where ls owershell locaLed ln shareolnL ?
Ans Cn Lhe SLarL menu cllck All rograms Cllck MlcrosofL ShareolnL 2010 roducLs Cllck
ShareolnL 2010 ManagemenL Shell

C lf you need golng Lo lnsLall a webparL or any cusLom soluLlon ln ShareolnL 2010 uslng owerShell
WhaL permlsslons do you need?
Ans ln order Lo use Wlndows owerShell for ShareolnL 2010 roducLs a user musL be a member of Lhe
ShareolnL_Shell_Access role on Lhe conflguraLlon and conLenL daLabase ln addlLlon Lo Lhls Lhe user
musL also be a member of Lhe WSS_AuMln_WC local group on Lhe compuLer where ShareolnL 2010
roducLs ls lnsLalled See 1he ueLalls below

ermlsslons for Wlndows owerShell SShellAdmln

ln order Lo use Wlndows owerShell for ShareolnL 2010 roducLs a user musL be a member of Lhe
ShareolnL_Shell_Access role on Lhe conflguraLlon and conLenL daLabase ln addlLlon Lo Lhls Lhe user
musL also be a member of Lhe WSS_AuMln_WC local group on Lhe compuLer where ShareolnL 2010
roducLs ls lnsLalled

1o add a user as ShareolnL_Shell_Access on Lhe ShareolnL daLabase use Lhe below powershell cmdleL
AddSShellAdmln

lease noLe LhaL Lo run Lhe above cmdleL you musL have* Membershlp ln Lhe securlLyadmln flxed server
role on Lhe SCL Server lnsLance
* Membershlp ln Lhe db_owner flxed daLabase role on all affecLed daLabases
* and local admlnlsLraLlve permlsslon on Lhe local compuLer

ln addlLlon Lo above some lmporLanL Lhlngs Lo noLe

* 1he user geLs added Lo Lhe WSS_Admln_WC group on all Web servers when Lhe user ls added Lo Lhe
ShareolnL_Shell_Access role
* lf Lhe LargeL daLabase does noL have a ShareolnL_Shell_Access role Lhe role ls auLomaLlcally creaLed
* lf you use Lhe daLabase parameLer Lhe user ls added Lo Lhe role on Lhe farm conflguraLlon daLabase
Lhe CenLral AdmlnlsLraLlon conLenL daLabase and Lhe speclfled daLabase uslng Lhe daLabase parameLer
ls Lhe preferred meLhod because mosL of Lhe admlnlsLraLlve operaLlons requlre access Lo Lhe CenLral
AdmlnlsLraLlon conLenL daLabase 1he cmdleL ls someLhlng llke below

AddSShellAdmln username uomalnnameuser daLabase uaLabase Culu

C Pow Lo llsL all Lhe commands ln owerShell ?
Ans CeLCommand * commands geLs you all Lhe owershell commands lor more commands see
1o Cpen Lhe Wlndows owerShell Sesslon

1 Cn Lhe SLarL menu cllck All rograms
2 Cllck MlcrosofL ShareolnL 2010 roducLs
3 Cllck ShareolnL 2010 ManagemenL Shell

noLe ?ou should have ShareolnL_Shell_Access role on Lhe conflguraLlon daLabase and you should be a
member of Lhe WSS_AuMln_WC local group on Lhe compuLer where ShareolnL Server 2010 ls
lnsLalled

Some of Lhe Common Commands and CperaLlons are

CreaLe Web AppllcaLlon varlable
$webapp CeLSWebAppllcaLlon hLLp//pravahamlnfol234/

CreaLe ShareolnL SlLe varlable (lnsLance of SSlLe)
$slLeurl hLLp//mysharepolnLslLe/
$CurslLenewob[ecL MlcrosofLShareolnLSSlLe($slLeurl)
Pere we have creaLed a varlable CurslLe whlch conLalns an lnsLance of Lype SSlLe now you can use lL
Lo ulsplay all webs ln Lhe slLe collecLlon
$CurslLeAllWebs more // LlsL all Webs ln Lhe SlLe

CreaLe Servlce AppllcaLlon varlable
$spapp CeLSServlceAppllcaLlon name ServlceAppllcaLlonulsplayname

CreaLe a WebappllcaLlon
new SWebAppllcaLlon AppllcaLlonoolname name of Lhe appllcaLlon pool name name of Lhe
new Web appllcaLlon orL orL on whlch Lhe Web appllcaLlon can be accessed PosLPeader
valld u8L asslgned Lo Lhe Web appllcaLlon LhaL musL correlaLe Lo Lhe alLernaLe access mapplng
conflguraLlon u8L Loadbalanced u8L for Lhe Web appllcaLlon AppllcaLlonoolAccounL user
accounL LhaL Lhls appllcaLlon pool wlll run as

ueleLe WebAppllcaLlon
8emoveSWebAppllcaLlon ldenLlLy u8L hLLp//slLename/ Conflrm

CreaLeueleLe a SlLe CollecLlon
CreaLe a SlLe collecLlon
CeLSWeb1emplaLe
$LemplaLe CeLSWeb1emplaLe S1S#0
newSSlLe url u8L for Lhe new slLe collecLlon CwnerAllas domalnuser 1emplaLe
$LemplaLe
Pere $LemplaLe ls a varlable Lo sLore Lhe Lype of LemplaLe we wanL Lo use whlle creaLlng a slLe
collecLlon

ueleLe a SlLe CollecLlon
8emoveSSlLe ldenLlLy u8L CradualueleLe
Pere u8L ls a slLe CollecLlon url

8ack8esLore a conLenL daLabase
1o 8ackup
8ackup Slarm ulrecLory 8ackup folder 8ackupMeLhod lLem ConLenL daLabase name verbose
8ackup folder ls a folder Lo save your backup
8ackupMeLhod Can Speclfy beLween lull or ulfferenLlal

1o 8esLore
8esLore Slarm ulrecLory 8ackup folder 8esLoreMeLhod CverwrlLe lLem ConLenL daLabase name
8ackupld verbose
lf you don'L know Lhe 8ackuplu you can dlsplay all Lhe backups uslng Lhe below command and geL Lhe
Culu of Lhe 8ackup
CeLS8ackupPlsLory ulrecLory 8ackup folder
?ou can check all Lhe 8ackup8esLore CperaLlons Pere

ueploy WebarL SolulLon ackage
lnsLall SWebarLack LlLeralaLh aLh1oCA8orwspllle name nameClWebarL
aLh1oCA8orwspllle ls Lhe full paLh Lo Lhe CA8 flle LhaL ls belng deployed
nameClWebarL ls Lhe name of Lhe Web arL LhaL ls belng deployed

lnsLall AcLlvaLe and ueacLlvaLe leaLure uslng Wlndows owershell
lnsLall leaLure
$MyleaLureld $(CeL SleaLure llmlL all where $_dlsplayname eq myfeaLurename)ld
lnsLall SleaLure $MyleaLureld

AcLlvaLeLnable leaLure
$slngleSlLeCollecLlon CeL SSlLe ldenLlLy hLLp//myslngleslLecollecLlonurl/
Lnable SleaLure $MyleaLureld url $slngleSlLeCollecLlonu8L

ueacLlvaLeulsable leaLure
$slngleSlLeCollecLlon CeLSSlLe ldenLlLy hLLp//myslngleslLecollecLlonurl/
ulsable SleaLure $MyleaLureld url $slngleSlLeCollecLlonu8L

Command 1C LlsL all Lhe owerShell Commands
CeLCommand SSnapln CeLCommand SSnapln MlcrosofLShareolnLowerShell" formaLLable
name CS2010_owerShell_CommandsLxL

Addlng a conLenL daLabase uslng owerShell ln ShareolnL 2010
1o aLLach an exlsLlng conLenL daLabase
MounLSConLenLuaLabase ConLenLub uaLabaseServer ubServer WebAppllcaLlon
hLLp//webappllcaLlonname/
ConLenLub ls Lhe conLenL daLabase Lo be aLLached
ubServer ls Lhe name of Lhe daLabase server
hLLp//webappllcaLlonname/ ls Lhe name of Lhe Web appllcaLlon Lo whlch Lhe conLenL daLabase ls belng
aLLached
1o deLach a conLenL daLabase
ulsmounLSConLenLuaLabase ConLenLd8name
Where ls Lhe name of Lhe conLenL daLabase

ShareolnL 2010 Wlndows owerShell Commands ll
Some more owerShell Commands
SlLe CollecLlon Commands

CreaLe SlLe CollecLlon
CeLSWeb1emplaLe
$LemplaLe CeLSWeb1emplaLe S1S#0
newSSlLe url CwnerAllas 1emplaLe $LemplaLe

ueleLe SlLe CollecLlon
8emoveSSlLe ldenLlLy u8L of slLe CollecLlon CradualueleLe

Change SlLe collecLlon CuoLas
SeLSSlLe ldenLlLy SlLeCollecLlon url MaxSlze CuoLa

Add slLe CollecLlon AdmlnlsLraLors
SeLSSlLe ldenLlLy SecondaryCwnerAllas

Lock or unlock a slLe collecLlon
SeLSSlLe ldenLlLy SlLe CollecLlon url LockSLaLe
ls one of Lhe followlng vales
# unlock 1o unlock Lhe slLe collecLlon and make lL avallable Lo users
# noAddlLlons 1o prevenL users from addlng new conLenL Lo Lhe slLe collecLlon updaLes and deleLlons
are sLlll allowed
# 8eadCnly 1o prevenL users from addlng updaLlng or deleLlng conLenL
# noAccess 1o prevenL access Lo conLenL compleLely users who aLLempL Lo access Lhe slLe recelve an
accessdenled message
CreaLe a slLe
newSSlLe hLLp//slLecollecLlon/slLes/SubslLe CwnerAllas uCMAlnusername Language 1033

You might also like