Skip Navigation LinksSharePoint and PowerShell

PowerShell commands:   
Purpose​ ​Command ​Notes
 to show all SharePoint subsites (engagement sites)​ foreach ( $_ in $spweb.webs) {$_.webs | select url} 
 To show methods and properties of powershell objects  (pipe object into it)​ get-childitem | get-member
List environmental variables  ​ ​Get-Childitem env: ​ ​To user env var's (such as USERNAME or USERPROFILE) address it by issueing :
$env:username
​Search for string to find illegal SharePoint 2010 file names  filename:"&" OR filename:"~" OR filename:"`" OR filename:"!" OR filename:"@" OR filename:"#" OR filename:"$" OR filename:"%" OR filename:"^"​
Enable SharePoint CLI commands to PoSH interpreter Add-PsSnapin Microsoft.SharePoint.Powershell​ ​Must have add-spshelladmin ran for your user name against config db minimum
​retrieve service account credentials ​​​get-svccredentials.zip ​http://www.sharepointlonghorn.com/Lists/Posts/Post.aspx?ID=11​
​Add-SPShellAdmin​Apply SPShellAdmin property to all SharePoint databases​foreach ($_. in $spdb){add-spshelladmin -username "$env:userdomain\$env:username" -database $_.id}This command is a faux pas - if you have the ability to run it against that database, you already have the property.  To make it functional, create a variable (such as $username) and populate it with the user that needs SPShellAdmin on the databases, and replace "$env:userdomain\$env:username" with $username
​Start (PoSH) with elevated permissions​in UAC environment, to get administrative access ​start powershell -verb runas​this will prompt the user to authorize the privilege elevation, therefore its not much good for unattended scripts, however in a pinch its useful for administrative work
​Where-Object​for filtering, partial selections, etc​where-object {$_.PropertyName -eq "Prop"}

​Valid operators:

-eq     =

-ne     !=

-Lt     <

-Le    ≤

-gt    >

-ge    

-Like  "property" <-- EXACT match

-match "prop*"   <-- Partial match

​Add a site to the Trusted Sites list
set-location "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
set-location ZoneMap\Domains
new-item BRAD-SERVER
set-location BRAD-SERVER
new-itemproperty . -Name http -Value 2 -Type DWORD

​BRAD-SERVER is the server name.

Thanks for this goes to: http://blog.mapdojo.com/2011/01/adding-trusted-site-using-powershell.html

​Set local execution policy to run local scripts​start powershell "-command set-ExecutionPolicy -executionpolicy remotesigned"  -verb runas
​Find and check in all documents currently checked out at a current URL and within all child sites (if applicable)Find-SPCheckedOutFiles.ps1​Must be ran on one of the SP Servers in the Farm.  Tested in SPS2010, should also work in 2013. might work in '07 with some minor modification