Friday, 9 December 2016

SharePoint PowerShell PnP

SharePoint and PowerShell PnP is soo cool.

Below are some of the snippets I have been playing with. Some of them are helpful for solving business requests asked by developers in the MSDN forums.

Small lines of code to get huge business requirements done in a fraction of a second...

1. Connection Code
$siteurl = "https://sharepointisgreat.sharepoint.com/sites/Dev"
$User = "admin@sharepointisgreat.onmicrosoft.com"
Connect-SPOnline -Url $siteurl -Credentials (Get-Credential)

2. List Operations
#Searching for command to add list
Get-Command *list*
help New-SPOLIst -Examples
New-SPOList -Title "SimplePSList" -Template GenericList -Url "SimplePSList"

#Add list item
help Add-SPOListItem -Examples
Add-SPOListItem -List "SimplePSList" -Values @{"Title"="Item1"}

#Update list item
help Set-SPOListItem -Examples
Set-SPOListItem -List "SimplePSList" -Identity 1 -Values @{"Title"="Item1-Updated"}

#Remove list item
help Remove-SPOListItem -Examples
Remove-SPOListItem -List "SimplePSList" -Identity 1

3. Adding Managed Metadata Column
#View all Taxonomy
Export-SPOTaxonomy -Path C:\assignments\Taxonomy.txt .. Get the term set path
$guid = [Guid]"ea45415d-f5a6-4344-b8a7-9b6c0d7fbf77"#New-Guid

#Add Field with GUID
Add-SPOTaxonomyField -List "StudentMMDemo" -DisplayName "Veggie" -InternalName "Veggie" -id $guid -TermSetPath "Edureka|Food|Vegetables"


#remove
Remove-SPOField -List "StudentMMDemo" -Identity "Veggie"

4. Add a Web Part to a Page /SitePages/samplePowerShell.aspx
$PageUrl = "/SitePages/samplePowerShell.aspx"
Add-SPOWebPartToWebPartPage -ServerRelativePageUrl $PageUrl -Path "C:\demo\SSOM\PowerShellCEWP.dwp" -ZoneId 0 -ZoneIndex 0  

5. Send Mail
Send-SPOMail -To $User -Subject "Mail From PowerShell" -Body "This is a sample mail from PowerShell code"

6. Add a file to a Document Library in SharePoint.Can also be used to move master pages.
Add-SPOFile -Folder "Shared Documents" -Path "C:\demo\UploadSP\Moving Full Trust Code to the Cloud.docx"

7. View Users
$siteurl = "https://sharepointisgreat-admin.sharepoint.com"
$User = "admin@sharepointisgreat.onmicrosoft.com"

Connect-SPOService -Url $siteurl -Credential (Get-Credential)
Get-SPOUser -Site $siteurl |select -Property *Login*

Saturday, 19 November 2016

Thank You Jeff for the PowerShell Jump Start tutorials

"Please paste the following in PowerShell ISE and execute"
$newline = "`r`n"
$message = ""
$message = $message +"`r`n"+[char[]][int[]](67,79,78,71,82,65,84,85,76,65,84,73,79,78,83)

$message = $message +"`r`n"+[char[]][int[]](69,84,69,82,78,65,76,32,83,85,67,67,69,83,83)

$message = $message +"`r`n"+"abcbestabcwishes".Replace("abc"," ")

$message = $message +"`r`n"+"You are soo brigxt ! Otxers need sunglasses!".Replace('x','h')

$message = $message +"`r`n"+"Wish u days full of qoney!".Replace('q','m')

$message = $message +"`r`n"+"May you always mile".Insert(15,'s')

$message = $message +"`r`n"+[char[]][int[]](72,97,112,112,121,32,70,111,114,101,118,101,114)

$message = $message +"`r`n"+[char[]][int[]](66,111,114,110,32,116,111,32,87,105,110)

$message = $message +"`r`n"+[char[]][int[]](69,116,101,114,110,97,108,32,83,116,114,101,110,110,103,116,104)

$message = $message +"`r`n"+[char[]][int[]](84,104,97,110,107,32,89,111,117)

Write-Host $message

Monday, 5 September 2016

PowerShell Real Time Examples

Below are some of the Real Time Examples of how SharePoint can saved, analysed or managed with the help of PowerShell:

1. Getting the Active Directory properties of SharePoint User.

SharePoint stores the user details in the form of claim token which needs to be decoded when we are trying to pull the details of user like the Site Collection of a Site Collection Administrator or Owner.
Here is the sample script which came to the rescue , instead of writing huge lines of code in C# in Visual Studio. Get-SPUser is fantastic if the User Profile stores all the AD details.

$ownerSP=Get-SPSiteAdministration -Url "http://w15-sp"|select OwnerLoginName
$m = [Microsoft.SharePoint.Administration.Claims.ClaimProviderManager]::Local
$ownerAD=$m.DecodeClaim($ownerSP.OwnerLoginName)
Get-ADUser -Identity $ownerAD -Properties * | select department,county


Thursday, 30 June 2016

Add Operations in SharePoint On Premise with POwerShell

Help Add-SPProjectLogLevelManager -examples
#Add Project entity to Project Sharepoint Site
Add-SPProjectLogLevelManager -Url http://w15-sp/pwa -EntityType Project -EntityUID "0798BF6A-F248-4F0F-8957-4D73993265BC"-LogLevel Verbose -Comments "xyz"
Get-SPProjectLogLevelManager -Url http://w15-sp/pwa
help Add-SPRoutingMachineInfo -examples
#Add routing target to specified identity to farm
$web = Get-SPWebApplication -Identity "http://w15-sp"
$rm = Get-SPRequestManagementSettings -Identity $web
Add-SPRoutingMachineInfo -RequestManagementSettings $rm -Name "w15-dc" -Availability Available
Get-SPRoutingMachineInfo -RequestManagementSettings $rm

#Adds a new machine pool.
 $web=Get-SPWebApplication -Identity "http://w15-sp"
   
 $rm=Get-SPRequestManagementSettings -Identity $web
   
 Add-SPRoutingMachinePool -RequestManagementSettings $rm -Name "w15-dc"
 Get-SPRoutingMachinePool -RequestManagementSettings $rm
   
   
help Add-SPRoutingRule -examples
# This examples adds a routing rule to the farm by using the $rm 
#   variables.
Add-SPRoutingRule -RequestManagementSettings $rm -Name "SampleRule"
Get-SPRoutingRule -RequestManagementSettings $rm

Note: The following content is in progress and please DO NOT use in production

Add-SPRoutingRule -RequestManagementSettings $rm -Name "SampleRule"

Get-SPRoutingRule -RequestManagementSettings $rm

#Add Scaleout database(IN Progress)

$appService = Get-SPServiceApplication |?{$_.DisplayName -like  "*App Management*"}

Add-SPScaleOutDatabase -ServiceApplication $appService -DatabaseName "sample"

 $appServiceProxy=Get-SPServiceApplicationProxy| ?{$_.DisplayName -like  "*App Management*"}

 Add-SPServiceApplicationProxyGroupMember -Identity 66c958d1-d10a-4880-bfc3-8b2646b8e4cd -Member fc413acb-f0b1-4617-b2f3-f2ef93c7f8bb

 Get-SPServiceApplicationProxyGroup

#Add new account

Add-SPSecureStoreSystemAccount -AccountName "contoso\garthf"

Get-SPSecureStoreSystemAccount

#Adds a user to the SharePoint_Shell_Access role for the specified database.
<#This example adds a new user named User1 to the SharePoint_Shell_Access role in 
    the farm configuration database only, and also ensures the user is added to the 
    WSS_Admin_WPG local group on each server in the farm.
    #>
Add-SPShellAdmin -UserName "contoso\garthf"

    
#This example adds a new user named garthf to the SharePoint_Shell_Access role in 
    #the farm configuration database only, and also ensures the user is added to the 
    #WSS_Admin_WPG local group on each server in the farm.

Add-SPShellAdmin -UserName CONTOSO\garthf
    
#This example adds a new user named User1 to the SharePoint_Shell_Access role in 
 # both the specified content database and the configuration database by passing a 
 #  database GUID to the cmdlet.   
$spDatabase = Get-SPContentDatabase |?{$_.Name –like “*Project*”}    
Add-SPShellAdmin -UserName CONTOSO\User1 -database $spDatabase.ID 
    
#This example adds a new user named garthf to the SharePoint_Shell_Access role in 
  #  both the specified Central Administration content database and the configuration 
  #  database.    
Get-SPDatabase | Where-Object {$_.WebApplication -like 
    "SPAdministrationWebApplication"} | Add-SPShellAdmin CONTOSO\garthf
    
   # This example adds a new user named garthf  to the SharePoint_Shell_Access role of 
    #both the specified content database and the configuration database by passing the 
    #name of the database to the cmdlet.

Get-SPDatabase | ?{$_.Name -eq "WSS_Content"} | Add-SPShellAdmin -Username 
    CONTOSO\garthf

Tuesday, 28 June 2016

Add/Update Operations on User Profile

#Turn on Security Trimming in Service Application
$upProxy = Get-SPServiceApplicationProxy |?{$_.DisplayName -like "*Profile*"}
Add-SPPluggableSecurityTrimmer -UserProfileApplicationProxyId $upProxy.ID
Get-SPPluggableSecurityTrimmer -UserProfileApplicationProxyId $upProxy.ID
Get-Help Add-SPPluggableSecurityTrimmer -examples

#Add Profile Leader
Add-SPProfileLeader -ProfileServiceApplicationProxy $upProxy -Name "contoso\alexd"
Get-SPProfileLeader -ProfileServiceApplicationProxy $upProxy
#Add User Profiel from different domain
Get-Help Add-SPProfileSyncConnection -examples
Add-SPProfileSyncConnection -ProfileServiceApplication $upProxy`
    -ConnectionForestName "fabrikam.com" -ConnectionDomain "Fabrikam" -ConnectionUserName "Testupa" `
    -ConnectionPassword convertto-securestring "Password1" -asplaintext -force `
    -ConnectionSynchronizationOU "OU=SharePoint Users,DC=fabrikam,DC=com"`

Saturday, 25 June 2016

Adds a user agent to a farm


Add-PSSnapin "Microsoft.SharePoint.PowerShell"                                  

Get-Help Add-SPInfoPathUserAgent -examples                                      

Get-SPInfoPathUserAgent                                                        

Add-SPInfoPathUserAgent -Name "something"

#View new agent

Get-SPInfoPathUserAgent

Thursday, 23 June 2016

Display all the lists in a SharePoint Site collection

This is a very simple set of code in PowerShell to find all the lists in SharePoint which are not default/hidden for all web sites under a site collection.


http://contoso.sharepoint.com


$spSite = Get-SPSite -Identity http://contoso.sharepoint.com

$spWebs = $spSite.AllWebs




Get-Date


foreach($spWeb in $spWebs)



{

$spWebTitle = $spWeb.Title

"Displaying Lists in Site::"+$spWebTitle

$spLists = $spWeb.Lists

foreach ($spList in $spLists)



{

$spList.Title



}

"List Count in site ::"+$spWebTitle + "::" + $spLists.Count

#Get-Date;



}



Tuesday, 14 June 2016

Creating a SharePoint Education Site

As I was exploring the SharePoint PowerShell commandlets, I got stuck with an interesting command related to SharePoint Education site.Add-SpEdu...
[In Progress[

References
http://blog.furuknap.net/sharepoint-education-installing-and-configuring

CRUD Operations in SharePoint using PowerShell

The following is a series of commands in SharePoint using PowerShell helping to perform many administrative tasks or even development tasks with ease.

Get-HElp Add-SPAppDeniedEndpoint -examples
#Stop Apps from accessing an endpoint
Add-SPAppDeniedEndpoint -Endpoint "_vti_bin/contoso/service.asmx"
Get-SPAppDeniedEndpointList
Get-Help Add-SPClaimTypeMapping -Examples
#Add a claim-https://technet.microsoft.com/en-us/library/ff607650.aspx
#Note: the New-SPClaimTYpeMapping worked and Add-SPClaimTYpeMapping is an example from msdn site.
Get-TrustedIdentityTokenIssuer -Identity "LiveIDSTS" | Add-SPClaimTypeMapping -IncomingClaimType "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier" -IncomingClaimTypeDisplayName "PUID" -LocalClaimType "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/thumbprint"
$map1 = New-SPClaimTypeMapping -IncomingClaimType "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" -IncomingClaimTypeDisplayName "EmailAddress" -SameAsIncoming
Get-Help Add-SPDiagnosticsPerformanceCounter -examples
<#This example adds the _Total instance of the counter % Processor Time in the
    category Processor on database servers.#>
Add-SPDiagnosticsPerformanceCounter -category Processor -counter "%Processor Time" -instance "_Total" -databaseserver
Get-SPDiagnosticsPerformanceCounter
Get-Help Add-SPDistributedCacheServiceInstance -examples -Online
#Add Distributed Cache
Add-SPDistributedCacheServiceInstance

SharePoint Actions or SharePoint Verbs in PowerShell

I just finished with the huge list of Get commands in SharePoint. Below is the list of all other verbs.
Please do not use them on a Production server directly. After a Add/Update/Delete, the Get commands are extremely powerful to view the results. And, wow, SharePoint Development team has done a wonderful job in creating such simple and powerful commandlets..Thanks a ton!
Add
BackUp
Clear
Connect
Convert
Copy
Disable
Disconnect
Dismount
Enable
Export
Get
Grant
Import
Initialise
Install
Invoke
Merge
Mount
Move
New
Pause
Publish
Receive
Register
Remove
Repair
Reset
Restart-SPAppInstanceJob
Restore
Resume
Revoke
Set
Split
Start
Stop
Suspend
Sync
Test
Unistall
Unpublish
Update
Upgrade

Saturday, 11 June 2016

SharePoint LIst of all Web Templates - GEt-SPWebTemplate

Title                                       Name                                      
-----                                       ----                                      
Globale Vorlage                             GLOBAL#0                                  
Teamwebsite                                 STS#0                                     
Leere Website                               STS#1                                     
Dokumentarbeitsbereich                      STS#2                                     
Standard-Besprechungsarbeitsbereich         MPS#0                                     
Leerer Besprechungsarbeitsbereich           MPS#1                                     
Entscheidung-Besprechungsarbeitsbereich     MPS#2                                     
Sozialer Besprechungsarbeitsbereich         MPS#3                                     
Mehrseitiger Besprechungsarbeitsbereich     MPS#4                                     
Zentrale Verwaltungssite                    CENTRALADMIN#0                            
Wiki-Website                                WIKI#0                                    
Blog                                        BLOG#0                                    
Gruppenarbeitssite                          SGS#0                                     
Mandantenverwaltungswebsite                 TENANTADMIN#0                             
App-Vorlage                                 APP#0                                     
App-Katalogwebsite                          APPCATALOG#0                              
Access Services-Site                        ACCSRV#0                                  
Access Services-Website (intern)            ACCSVC#0                                  
Access Services-Website                     ACCSVC#1                                  
Dokumentcenter                              BDR#0                                     
Entwicklerwebsite                           DEV#0                                     
Akademische Bibliothek                      DOCMARKETPLACESITE#0                      
eDiscovery Center                           EDISC#0                                   
eDiscovery-Fall                             EDISC#1                                   
(veraltet) Datenarchiv                      OFFILE#0                                  
Datenarchiv                                 OFFILE#1                                  
Verwaltungssite der gemeinsamen Dienste     OSRV#0                                    
PowerPivot-Site                             PowerPivot#0                              
PerformancePoint                            PPSMASite#0                               
Business Intelligence Center                BICenterSite#0                            
Project Web App-Site                        PWA#0                                     
Microsoft Project-Website                   PWS#0                                     
SharePoint Portal Server-Website            SPS#0                                     
Persönlicher SharePoint Portal Server-Sp... SPSPERS#0                                 
Persönlicher SharePoint Portal Server-Be... SPSPERS#2                                 
Persönlicher SharePoint Portal Server-Be... SPSPERS#3                                 
Persönlicher SharePoint Portal Server-Be... SPSPERS#4                                 
Leerer persönlicher SharePoint Portal Se... SPSPERS#5                                 
Personalisierungswebsite                    SPSMSITE#0                                
Bereichsvorlage 'Inhalt'                    SPSTOC#0                                  
Bereichsvorlage 'Thema'                     SPSTOPIC#0                                
Website 'Nachrichten'                       SPSNEWS#0                                 
Veröffentlichungswebsite                    CMSPUBLISHING#0                           
Veröffentlichungssite                       BLANKINTERNET#0                           
Website für Presseerklärungen               BLANKINTERNET#1                           
Veröffentlichungssite mit Workflow          BLANKINTERNET#2                           
Website 'Nachrichten'                       SPSNHOME#0                                
Websiteverzeichnis                          SPSSITES#0                                
Bereichsvorlage 'Community'                 SPSCOMMU#0                                
Berichtscenter                              SPSREPORTCENTER#0                         
Zusammenarbeitsportal                       SPSPORTAL#0                               
Unternehmenssuchcenter                      SRCHCEN#0                                 
Profile                                     PROFILES#0                                
Veröffentlichungsportal                     BLANKINTERNETCONTAINER#0                  
Mein Websitehost                            SPSMSITEHOST#0                            
Unternehmenswiki                            ENTERWIKI#0                               
Projektwebsite                              PROJECTSITE#0                             
Produktkatalog                              PRODUCTCATALOG#0                          
Communitywebsite                            COMMUNITY#0                               
Communityportal                             COMMUNITYPORTAL#0                         
Basissuchcenter                             SRCHCENTERLITE#0                          
Basissuchcenter                             SRCHCENTERLITE#1                          
Visio-Prozessrepository                     vispr#0                                   
Globale Vorlage                             GLOBAL#0                                  
Teamwebsite                                 STS#0                                     
Leere Website                               STS#1                                     
Dokumentarbeitsbereich                      STS#2                                     
Standard-Besprechungsarbeitsbereich         MPS#0                                     
Leerer Besprechungsarbeitsbereich           MPS#1                                     
Entscheidung-Besprechungsarbeitsbereich     MPS#2                                     
Sozialer Besprechungsarbeitsbereich         MPS#3                                     
Mehrseitiger Besprechungsarbeitsbereich     MPS#4                                     
Zentrale Verwaltungssite                    CENTRALADMIN#0                            
Wiki-Website                                WIKI#0                                    
Blog                                        BLOG#0                                    
Gruppenarbeitssite                          SGS#0                                     
Mandantenverwaltungswebsite                 TENANTADMIN#0                             
Access Services-Site                        ACCSRV#0                                  
Posten-Webdatenbank                         ACCSRV#1                                  
Gemeinnützige Spenden-Webdatenbank          ACCSRV#3                                  
Kontakte-Webdatenbank                       ACCSRV#4                                  
Probleme-Webdatenbank                       ACCSRV#6                                  
Projekte-Webdatenbank                       ACCSRV#5                                  
Dokumentcenter                              BDR#0                                     
(veraltet) Datenarchiv                      OFFILE#0                                  
Datenarchiv                                 OFFILE#1                                  
Verwaltungssite der gemeinsamen Dienste     OSRV#0                                    
PerformancePoint                            PPSMASite#0                               
Business Intelligence Center                BICenterSite#0                            
Project Web App-Site                        PWA#0                                     
Microsoft Project-Website                   PWS#0                                     
SharePoint Portal Server-Website            SPS#0                                     
SharePoint Portal Server - Persönlicher ... SPSPERS#0                                 
Personalisierungswebsite                    SPSMSITE#0                                
Bereichsvorlage 'Inhalt'                    SPSTOC#0                                  
Bereichsvorlage 'Thema'                     SPSTOPIC#0                                
Website 'Nachrichten'                       SPSNEWS#0                                 
Veröffentlichungswebsite                    CMSPUBLISHING#0                           
Veröffentlichungssite                       BLANKINTERNET#0                           
Website für Presseerklärungen               BLANKINTERNET#1                           
Veröffentlichungssite mit Workflow          BLANKINTERNET#2                           
Website 'Nachrichten'                       SPSNHOME#0                                
Websiteverzeichnis                          SPSSITES#0                                
Bereichsvorlage 'Community'                 SPSCOMMU#0                                
Berichtscenter                              SPSREPORTCENTER#0                         
Zusammenarbeitsportal                       SPSPORTAL#0                               
Unternehmenssuchcenter                      SRCHCEN#0                                 
Profile                                     PROFILES#0                                
Veröffentlichungsportal                     BLANKINTERNETCONTAINER#0                  
Mein Websitehost                            SPSMSITEHOST#0                            
Unternehmenswiki                            ENTERWIKI#0                               
Basissuchcenter                             SRCHCENTERLITE#0                          
Basissuchcenter                             SRCHCENTERLITE#1                          
FAST Search-Center                          SRCHCENTERFAST#0                          
Visio-Prozessrepository                     vispr#0                                   
Global template                             GLOBAL#0                                  
Team Site                                   STS#0                                     
Blank Site                                  STS#1                                     
Document Workspace                          STS#2                                     
Basic Meeting Workspace                     MPS#0                                     
Blank Meeting Workspace                     MPS#1                                     
Decision Meeting Workspace                  MPS#2                                     
Social Meeting Workspace                    MPS#3                                     
Multipage Meeting Workspace                 MPS#4                                     
Central Admin Site                          CENTRALADMIN#0                            
Wiki Site                                   WIKI#0                                    
Blog                                        BLOG#0                                    
Group Work Site                             SGS#0                                     
Tenant Admin Site                           TENANTADMIN#0                             
App Template                                APP#0                                     
App Catalog Site                            APPCATALOG#0                              
Access Services Site                        ACCSRV#0                                  
Access Services Site Internal               ACCSVC#0                                  
Access Services Site                        ACCSVC#1                                  
Document Center                             BDR#0                                     
Developer Site                              DEV#0                                     
Academic Library                            DOCMARKETPLACESITE#0                      
eDiscovery Center                           EDISC#0                                   
eDiscovery Case                             EDISC#1                                   
(obsolete) Records Center                   OFFILE#0                                  
Records Center                              OFFILE#1                                  
Shared Services Administration Site         OSRV#0                                    
PowerPivot Site                             PowerPivot#0                              
PerformancePoint                            PPSMASite#0                               
Business Intelligence Center                BICenterSite#0                            
Project Web App Site                        PWA#0                                     
Microsoft Project Site                      PWS#0                                     
SharePoint Portal Server Site               SPS#0                                     
SharePoint Portal Server Personal Space     SPSPERS#0                                 
Storage And Social SharePoint Portal Ser... SPSPERS#2                                 
Storage Only SharePoint Portal Server Pe... SPSPERS#3                                 
Social Only SharePoint Portal Server Per... SPSPERS#4                                 
Empty SharePoint Portal Server Personal ... SPSPERS#5                                 
Personalization Site                        SPSMSITE#0                                
Contents area Template                      SPSTOC#0                                  
Topic area template                         SPSTOPIC#0                                
News Site                                   SPSNEWS#0                                 
Publishing Site                             CMSPUBLISHING#0                           
Publishing Site                             BLANKINTERNET#0                           
Press Releases Site                         BLANKINTERNET#1                           
Publishing Site with Workflow               BLANKINTERNET#2                           
News Site                                   SPSNHOME#0                                
Site Directory                              SPSSITES#0                                
Community area template                     SPSCOMMU#0                                
Report Center                               SPSREPORTCENTER#0                         
Collaboration Portal                        SPSPORTAL#0                               
Enterprise Search Center                    SRCHCEN#0                                 
Profiles                                    PROFILES#0                                
Publishing Portal                           BLANKINTERNETCONTAINER#0                  
My Site Host                                SPSMSITEHOST#0                            
Enterprise Wiki                             ENTERWIKI#0                               
Project Site                                PROJECTSITE#0                             
Product Catalog                             PRODUCTCATALOG#0                          
Community Site                              COMMUNITY#0                               
Community Portal                            COMMUNITYPORTAL#0                         
Basic Search Center                         SRCHCENTERLITE#0                          
Basic Search Center                         SRCHCENTERLITE#1                          
Visio Process Repository                    visprus#0                                 
Global template                             GLOBAL#0                                  
Team Site                                   STS#0                                     
Blank Site                                  STS#1                                     
Document Workspace                          STS#2                                     
Basic Meeting Workspace                     MPS#0                                     
Blank Meeting Workspace                     MPS#1                                     
Decision Meeting Workspace                  MPS#2                                     
Social Meeting Workspace                    MPS#3                                     
Multipage Meeting Workspace                 MPS#4                                     
Central Admin Site                          CENTRALADMIN#0                            
Wiki Site                                   WIKI#0                                    
Blog                                        BLOG#0                                    
Group Work Site                             SGS#0                                     
Tenant Admin Site                           TENANTADMIN#0                             
Access Services Site                        ACCSRV#0                                  
Assets Web Database                         ACCSRV#1                                  
Charitable Contributions Web Database       ACCSRV#3                                  
Contacts Web Database                       ACCSRV#4                                  
Issues Web Database                         ACCSRV#6                                  
Projects Web Database                       ACCSRV#5                                  
Document Center                             BDR#0                                     
(obsolete) Records Center                   OFFILE#0                                  
Records Center                              OFFILE#1                                  
Shared Services Administration Site         OSRV#0                                    
PowerPivot Site                             PowerPivot#0                              
PerformancePoint                            PPSMASite#0                               
Business Intelligence Center                BICenterSite#0                            
Project Web App Site                        PWA#0                                     
Microsoft Project Site                      PWS#0                                     
SharePoint Portal Server Site               SPS#0                                     
SharePoint Portal Server Personal Space     SPSPERS#0                                 
Personalization Site                        SPSMSITE#0                                
Contents area Template                      SPSTOC#0                                  
Topic area template                         SPSTOPIC#0                                
News Site                                   SPSNEWS#0                                 
Publishing Site                             CMSPUBLISHING#0                           
Publishing Site                             BLANKINTERNET#0                           
Press Releases Site                         BLANKINTERNET#1                           
Publishing Site with Workflow               BLANKINTERNET#2                           
News Site                                   SPSNHOME#0                                
Site Directory                              SPSSITES#0                                
Community area template                     SPSCOMMU#0                                
Report Center                               SPSREPORTCENTER#0                         
Collaboration Portal                        SPSPORTAL#0                               
Enterprise Search Center                    SRCHCEN#0                                 
Profiles                                    PROFILES#0                                
Publishing Portal                           BLANKINTERNETCONTAINER#0                  
My Site Host                                SPSMSITEHOST#0                            
Enterprise Wiki                             ENTERWIKI#0                               
Basic Search Center                         SRCHCENTERLITE#0                          
Basic Search Center                         SRCHCENTERLITE#1                          
FAST Search Center                          SRCHCENTERFAST#0                          
Visio Process Repository                    visprus#0                                 



Thursday, 7 April 2016

OneLiners in PowerShell with SharePoint for Locale

[Microsoft.SharePoint.SpLocale]
$lcid = $spWeb.Locale
$lcid.CultureTypes
$spWEb = Get-SpWEb -Site "http://w15-sp"
$spWeb.Locale
$spWeb.Locale.Calendar
$spWeb.Locale.CompareInfo
$spWeb.Locale.CultureTypes
$spWeb.Locale.DateTimeFormat
$spWeb.Locale.DisplayName
#Installed Languages
$spWeb.RegionalSettings.InstalledLanguages
#View Locales
$spWEb.RegionalSettings.Locales

Thursday, 31 March 2016

OneLiners in PowerShell with SharePoint for Fields/Content Types

$spWeb= Get-SPWeb -Site "http:/intranet.contoso.com"
$spWeb.Fields | select Id,Title
$spWeb.Fields.Count
#Search for a field
#Add a Field location
$location = $spWeb.Fields| ?{$_.Title -like "Location"}
#View all FieldTypes
[System.Enum]::GetNames([Microsoft.SharePoint.SPFieldType])
if($location -eq $null)
{
$required = $false
$spWeb.Fields.Add("Location",[Microsoft.SharePoint.SPFieldType]::Geolocation,$required)
$spWeb.Update()
}
#View Fields of Type Text
$spWeb.Fields | ?{$_.Type -like "*Text*"}|select Title
$location = $spWeb.Fields["Location"]
#New content Type Location and add field to content Type
#$spWeb.ContentTypes["Holiday"].FieldLinks|select NAme
$spWeb.ContentTypes["Holiday"].FieldLinks.Add($location)
$spWeb.Update()

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$spWEb = Get-SpWeb -site "http://w15-sp"
$spWeb.FieldTypeDefinitionCollection
$spWeb.FieldTypeDefinitionCollection | select TypeName
#View count of field types
$spWeb.FieldTypeDefinitionCollection.Count
#View HTML field type
$spWeb.FieldTypeDefinitionCollection|?{$_.typeName -eq "HTML"}
#File dialog Post process id
$spWeb.FileDialogPostProcessorId
#View all files
$spWEb.Files
$spWEb.Files|select Url
$spWEb.FirstUniqueAncestor
$spWeb.FirstUniqueAncestorSecurableObject
$spWeb.FirstUniqueAncestorWeb
$spWEb.FirstUniqueRoleDefinitionWeb
$spWEb.Folders|select url

Tuesday, 15 March 2016

SharePoint List

#Create a list demo by deleting existing list
$spWeb = Get-SPWeb -Site "http://w15-sp"
$spList = $spWeb.Lists["demo"]

if($spList -ne $null){
#delete list demo if already present
$listguid = $spList.ID;
$spLIst.Lists.Delete($listguid);
$spWeb.Update();
}
#New list Demo
$templateType = [Microsoft.SharePoint.SPListTemplateType]::DocumentLibrary
$spWeb.Lists.Add("Demo","Demo Document Library",$templateType);
$spWEb.Update()
#Adding column
$spList = $spWeb.Lists["demo"]
#Title,FieldType,REquiredIndicator
$spList.Fields.Add("Color",[Microsoft.SharePoint.SPFieldType]::Text,1);
$spList.Update();
$spWeb.Update();

Wednesday, 9 March 2016

OnLiners in PowerShell and SharePoint SPView

#Create a new View simple
$spWeb = Get-SPWeb -Site "http://w15-sp"
$spList=$spWeb.Lists["Documents"];
$spViews = $spList.Views["NewView"]
#$spViewFields=$spViews.ViewFields
#Got from ViewFields $fields=@("DocIcon","LinkFilename","Modified","Editor")
#$spViews | select Query
$query="<OrderBy><FieldRef Name='FileLeafRef'/></OrderBy>"
$spViews.Add("NewView1",$fields,$query,10,$false,$false);

Tuesday, 8 March 2016

One Liners PowerShell and SharePoint with SPUSer

#Add Users
$spSite = Get-SPSite -Identity "http://intranet.contoso.com/sites/contoso"
New-SPWeb -Url "http://intranet.contoso.com/sites/contoso/demo" -Template "STS#1"
$spWeb= Get-SPWeb -Identity http://intranet.contoso.com/sites/demo"
New-SPUser -UserAlias "contoso\alexw" -Web $spWeb
New-SPUser -UserAlias "contoso\alexd" -Web $spWeb
New-SPUser -UserAlias "Project Phoenix" -Web $spWeb

Get-SPUser -Identity "contoso\alexw" -Web $spWeb
Get-SPUser -Identity "contoso\alexd" -Web $spWeb
Get-SPUser -UserAlias "Project Phoenix" -Web $spWeb
#Update Display Name
Set-SPUser -Identity $usrID -DisplayName $newUserName -Web $spWeb
#Update using Role Assignment
$spSite = Get-SPSite -Identity "http://intranet.contoso.com/sites/contoso"
$spWeb= Get-SPWeb -Identity http://intranet.contoso.com/sites/demo"
$startString ="Alex"
$newString ="AlexN"
$members=$spWeb.RoleAssignments;
foreach($member in $members)
{
 $usrID = $member.Member.UserLogin
 $usrName = $member.Member.Name
 $filterUser = $usrName -match $startString
 if($filterUser -eq $true)
 {
 "Old Display Name is $usrName"
 "For Users Login:: $usrID"
 #Updating DisplayName.
 Set-SPUser -Identity $usrID -DisplayName $newUserName -Web $spWeb
 $spWeb.Update();
 }
}
#Update using Permissions(This method is obsolete.Use RoleAssignment instead)
$spSite = Get-SPSite -Identity "http://intranet.contoso.com/sites/contoso"
$spWeb= Get-SPWeb -Identity http://intranet.contoso.com/sites/demo"
$startString ="Alex"
$newString ="AlexN"
$members=$spWeb.Permissions;
foreach($member in $members)
{
 $usrID = $member.Member.UserLogin
 $usrName = $member.Member.Name
 $filterUser = $usrName -match $startString
 if($filterUser -eq $true)
 {
 "Old Display Name is $usrName"
 "For Users Login:: $usrID"
 #Updating DisplayName.
 Set-SPUser -Identity $usrID -DisplayName $newUserName -Web $spWeb
 $spWeb.Update();
 }
}

#View Users after Updation
$spSite = Get-SPSite -Identity "http://intranet.contoso.com/sites/contoso"
$spWeb= Get-SPWeb -Identity http://intranet.contoso.com/sites/demo"
$startString ="Alex"
$newString ="AlexN"
$users=$spWeb.AllUsers;
foreach($user in $users)
{
 $usrID = $user.UserLogin
 $usrName = $user.Name
 $filterUser = $usrName -match $startString
 if($filterUser -eq $true)
 {
 "New Display Name is $usrName"
 "For Users Login:: $usrID"

 }
}
#Removing Users
$spSite = Get-SPSite -Identity "http://intranet.contoso.com/sites/contoso"
$spWeb= Get-SPWeb -Identity http://intranet.contoso.com/sites/demo"
$startString ="Alex"
$newString ="AlexN"
$users=$spWeb.AllUsers;
foreach($user in $users)
{
 $usrID = $user.UserLogin
 $usrName = $user.Name
 $filterUser = $usrName -match $startString
 if($filterUser -eq $true)
 {
 "Removing User with  Display Name is $usrName"
 "For Users Login:: $usrID"
 $spWeb.Permissions.Remove($user);
 $spWeb.Update();

 }
}
#Updating Users using All Users
$spSite = Get-SPSite -Identity "http://intranet.contoso.com/sites/contoso"
$spWeb= Get-SPWeb -Identity http://intranet.contoso.com/sites/demo"
$startString ="Alex"
$newString ="AlexN"
$users=$spWeb.AllUsers;
foreach($user in $users)
{
 $usrID = $user.UserLogin
 $usrName = $user.Name
 $filterUser = $usrName -match $startString
 if($filterUser -eq $true)
 {
 "Old Display Name is $usrName"
 "For Users Login:: $usrID"
 #Updating DisplayName.
 Set-SPUser -Identity $usrID -DisplayName $newUserName -Web $spWeb
 $spWeb.Update();
 }
}
#Display Users
$users=$spWeb.AllWebs;
foreach($user in $users)
{
 $user
}
#View User Information List
$spList=$spWeb.SiteUserInfoList


$spWeb.SiteUserInfoList
#View all Users
$spUserList=$spWeb.SiteUserInfoList
$spUsers=$spUserList.Items
foreach($spUser in $spUsers)
{
$spUser| select ID,Title
}

Monday, 7 March 2016

PowerShell and SharePoint with SPUser for each list

#Reading the Web Url
$spWeb= Get-SPWeb -Identity "http://intranet.contoso.com/sites/contoso/Departments/Finance"
if($spWeb -eq $null) {    
Write-Host "The site URL is not valid"
}
#Reading all the lists
$spLists = $spWeb.Lists;
if($spLists -eq $null) {   
 Write-Host "The site has no lists."
} foreach($list in $spLists)
{    
$title = ($list).Title;   
 $listUrl = ($list).ParentWebUrl;    
Write-Host "Listing Permissions for List $title in $listUrl"    
($list).Permissions | select member -Unique|sort member
}

Thursday, 3 March 2016

One Liners for PowerShell with SharePoint for SPWeb

#View all SpWeb.(If Access isssue try Get-SPContentDatabase | Add-SPShellAdmin "contoso\administrator")
Get-SPWebApplication | Get-SPSite -Limit All | Get-SpWeb -limit All | format-table -wrap
#View count of all subsites
Get-SPWebApplication | Get-SPSite -Limit All| Get-SpWeb -limit All | measure
#Get subsite for a site collection
Get-SpWeb -Site "http://w15-sp" -Limit All
Get-SpWeb -Identity "http://intranet.contoso.com/sites/contoso/blog2" -Limit All
#View all subsites
Get-SpSite -Identity "http://intranet.contoso.com/sites/contoso" | Get-SPWeb
#View all subsites under a URL
Get-SpWeb -Identity "http://intranet.contoso.com/sites/contoso/*" -Limit ALL|Format-Table -Wrap
#View Team sites
Get-SpWeb -Site "http://it.contoso.com/sites/newTeam" -Filter {$_.Template -eq "STS#0"}
#View all different site templates used
Get-SPWebApplication | Get-SPSite -Limit All| Get-SpWeb -limit All | select WEbTemplate -Unique
#View sites grouped by Templated
Get-SPWebApplication | Get-SPSite -Limit All| Get-SpWeb -limit All | select Url,WEbTemplate |group WebTemplate

#View subsites using  template BLANKINTERNET 
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "BLANKINTERNET"} -Limit ALL|format-table -wrap                                                                                                                    
#View subsites using  template BLOG 
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "BLOG"} -Limit ALL|format-table -wrap                                                                                                                               
#View subsites using  template BICENTERSITE or Business Intellligence Excel/PowerPoint/Viso          
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "BICENTERSITE"} -Limit ALL|format-table -wrap                                                                                                             
#View subsites using  template PRODUCTCATALOG or Retail/Sale related
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "PRODUCTCATALOG"} -Limit ALL|format-table -wrap                                                                                                                      
#View subsites using  template CMSPUBLISHING  
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "CMSPUBLISHING"} -Limit ALL|format-table -wrap                                                                                                                     
#View subsites using  template COMMUNITY  or Social Interactive Sites
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "COMMUNITY"} -Limit ALL|format-table -wrap                                                                                                                        
#View subsites using  template SRCHCEN or Search Site
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "SRCHCEN"} -Limit ALL|format-table -wrap                                                                                                                         
#View subsites using  template PROJECTSITE  
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "PROJECTSITE"} -Limit ALL|format-table -wrap                                                                                                                       
#View subsites using  template STS  or Team Site   
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "STS"} -Limit ALL|format-table -wrap                                                                                                                            
#View subsites using  template SGS or Engineering related 
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "SGS"} -Limit ALL|format-table -wrap                                                                                                                             
#View subsites using  template VISPRUS  or Compliance/Proposal related 
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "VISPRUS"} -Limit ALL|format-table -wrap                                                                                                                        
#View subsites using  template ENTERWIKI or Enterprise Wiki  
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "ENTERWIKI"} -Limit ALL|format-table -wrap                                                                                                                        
#View subsites using  template BDR   or Document Center
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "BDR"} -Limit ALL|format-table -wrap                                                                                                                              
#View subsites using  template OFFILE or Record Center        
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "OFFILE"} -Limit ALL|format-table -wrap                                                                                                                     
#View subsites using  template EDISC  or Ediscovery sites 
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "EDISC"} -Limit ALL|format-table -wrap                                                                                                                          
#View subsites using  template SPSPERS or personal sites
Get-SpSite -Limit ALL| Get-SPWeb -Filter {$_.Template -eq "SPSPERS"} -Limit ALL|format-table -wrap
#Users
#View all Users
(Get-SpWeb -Identity "http://w15-sp").AllUsers
#View Site Users
(Get-SpWeb -Identity "http://w15-sp").SiteUsers
(Get-SpWeb -Identity "http://w15-sp").SiteAdministrators
#View sites where chris is administrator
Get-SPWEbApplication | Get-SPSite -Limit All|Get-SPWEb -Limit All|?{$_.SiteAdministrators -like "*chris*"}

Properties of SPWeb
#View Alerts
(Get-SPWeb -Site "http://w15-sp").Alerts
$spWeb = Get-SPWeb -Site "http://w15-sp"
#IS Anonymous Access enabled(Mostly false
$spWeb.AllowAnonymousAccess
#Allow Automatic ASPX page rendering(false)
$spWEb.AllowAutomaticASPXPageIndexing
#AllowDesigner for Current User(true)
$spWEb.AllowDesignerForCurrentUser
$spweb.AllowMasterPageEditingForCurrentUser
#AllowRevertFromTemplateForCurrentUser(true)
$spweb.AllowRevertFromTemplateForCurrentUser;
#Allow Unsafe updates(true)
$spWEb.AllowUnsafeUpdates;
#View All Properties
$spweb.AllProperties|format-table -wrap
#View Associated Group
$spWEb.AllProperties["vti_associategroups"]
##FollowLinkEnabled
$spWeb.AllProperties["FollowLinkEnabled"]
#associateownergroup
$spWeb.AllProperties["vti_associateownergroup"]
#enabledhelpcollections
$spWeb.AllProperties["enabledhelpcollections"]
#Language
$spWeb.AllProperties["vti_defaultlanguage"]
#Taxonomy hidden list
$spWeb.AllProperties["taxonomyhiddenlist"]
#Mail Url
$spWeb.AllProperties["ExchangeTeamMailboxSiteCollectionUrl"]
#Disabled Help Collectins
$spWeb.AllProperties["disabledhelpcollections"]
#profileschemaversion
$spWeb.AllProperties["profileschemaversion"]                                                              
#MailUrl                                                    
$spWeb.AllProperties["ExchangeTeamMailboxOWAUrl"]
#Associated Memebr Group                
$spWeb.AllProperties["vti_associatemembergroup"]
#vti_extenderversion
$spWeb.AllProperties["vti_extenderversion"]
#Visitor Group
$spWeb.AllProperties["vti_associatevisitorgroup"]
#UPload Page
$spWeb.AllProperties["vti_customuploadpage"]
#Mail Site ID
$spWeb.AllProperties["ExchangeTeamMailboxSiteID"]
#Script Safe Internal Page
$spWeb.AllProperties["__ScriptSafeInternalPages"]
#Email Address
$spWeb.AllProperties["ExchangeTeamMailboxEmailAddress"]
#Categories
$spWeb.AllProperties["vti_categories"]
#CSS File cache
$spWeb.AllProperties["vti_mastercssfilecache"]
#List policy
$spWeb.AllProperties["allowslistpolicy"]
#Approval levels
$spWeb.AllProperties["vti_approvallevels"]
#Associated groups
$spWeb.AllProperties["vti_createdassociategroups"]
$spWeb.AllProperties["ExchangeTeamMailboxSharePointUrl"]

#SpWeb and Users
$spWeb=Get-SPWEb -Site "http://w15-sp"
#All Roles for Current USer
$spWeb.AllRolesForCurrentUser
#Count of Roles for current user
$spWeb.AllRolesForCurrentUser.Count
#Xml
$spWeb.AllRolesForCurrentUser.Xml
#Name
$spWeb.AllRolesForCurrentUser|select Name
#Id
$spWeb.AllRolesForCurrentUser|select Id
#View all users
$spWeb.AllUsers
#Count of USers
$spWEb.AllUsers.Count
#Is Synchronised
$spWEb.AllUsers.IsSynchronized
#RetriveAlRoles(false)
$spweb.AllUsers.RetrieveAllRoles
#SchemaXmlEx
$spweb.AllUsers.SchemaXmlEx
#View user Login and Display NAme
$spWeb.AllUsers.SyncRoot
#Upgraded Persisted Properties
$spweb.AllUsers.UpgradedPersistedProperties
#View the web
$spWEb.AllUsers.Web
#XML
$spWEb.AllUsers.XML
$spWeb.AllUsers.XmlEx
$spWEb.AllUsers.Add("contoso\alexd","alexd@contoso.com","Alex D","Notes")


#Groups

#Web Group related Info

$spWeb.AssociatedGroups|select Name

$spWeb.AssociatedGroups|select Name,Users,Xml

$spWeb.AssociatedMemberGroup

$spWeb.AssociatedOwnerGroup

$spWeb.AssociatedVisitorGroup



$spWeb = Get-SPWeb -Site "http://w15-sp"

#Custom JS Url

$spWeb.CustomJavaScriptFileUrl

#Audit

$spWEb.Audit

#Authentication Mode

$spWeb.AuthenticationMode

#Author

$spWEb.Author

#Available Content Types Count

$spWeb.AvailableContentTypes.Count

$spContentTypes = $spWeb.AvailableContentTypes

#View Deatails of item contetn type

$itemContentType = $spContentTypes| ?{$_.Name -eq "Item"}

#View Description(Create a new list item.)

$itemContentType.Description

$itemContentType.DescriptionResource

#FormTemplateName (ListForm)

$itemContentType.DisplayFormTemplateName

#FormUrl

$itemContentType.DisplayFormUrl

$itemContentType.DocumentTemplate

$itemContentType.DocumentTemplateUrl

#Edit Form(ListForm)

$itemContentType.EditFormTemplateName

$itemContentType.EditFormUrl

$itemContentType.EventReceivers

#Guid

$itemContentType.FeatureId

$itemContentType.FieldLinks | select Id,Name,Hidden,Required,SchemaXml

$itemContentType.Fields|select Id,StaticName,FieldValuetype

$spWeb.AvailableFields | select Title,Type,Group
$spWeb.CacheAllSchema
#Client Form Web Data
$spWeb.ClientFormWebData
$spWeb.ClientFormWebData.WebUrl
$spWeb.ClientFormWebData.AllowScriptableWebParts
$spWeb.ClientFormWebData.PermissionCustomizePages
$spWeb.ClientFormWebData.LCID

$spWeb.ClientFormWebData.CurrentUserId



#View client tag
$spweb.ClientTag
#Config data of web
$spWeb.Configuration
#Count of content types
$spweb.ContentTypes | measure
$spweb.ContentTypes | select Id,Name,ReadOnly,Fields
#Web creation date
$spWeb.Created

#Currency Locale ID
$spWeb.CurrencyLocaleID
#Current Change Token
$spWeb.CurrentChangeToken
#Current User
$spWeb.CurrentUser
#$JS File Url
$spWeb.CustomJavaScriptFileUrl
#Custom Master url
#/_catalogs/masterpage/seattle.master
$spWeb.CustomMasterUrl

$spWeb = Get-SpWeb -Site "http://w15-sp"
#LAYOUTS UPLOAD
$spWeb.CustomUploadPage
#Data Retrival settings
$spWeb.DataRetrievalServicesSettings
$spWeb.DataRetrievalServicesSettings.DataSourceControlEnabled
$spWeb.DataRetrievalServicesSettings.EnabledOleDbProviders|format-list *
$spWeb.DataRetrievalServicesSettings.MaxResponseSize
$spWeb.DataRetrievalServicesSettings.UpdateAllowed
$spWeb.DataRetrievalServicesSettings.RequestTimeout
$spWeb.DataRetrievalServicesSettings.ServicesEnabled
#Web Description
$spWeb.Description
$spWeb.DescriptionResource
#Doc Templates
$spWeb.DocTemplates | select Name,Type
$spWeb.DocumentLibraryCalloutOfficeWebAppPreviewersDisabled
#Is presence Enabled
$spWeb.EffectiveBasePermissions
$spWeb.EffectivePresenceEnabled
$spWeb.EmailInsertsEnabled
$spWeb.EnableMinimalDownload
$spWeb.EventHandlersEnabled
$spWeb.EventReceivers | select Id, Name
$spWeb.ExcludeFromOfflineClient
$spWeb.ExecuteUrl
$spWeb.Exists
$spWeb.ExternalSecurityProviderSetting

#Feature Definitions
$spWEb.FeatureDefinitions
#Features related to a Web
$spWEb.Features
$spWEb.Features.Count
$spWEb.Features | select * |?{$_.FeatureDefinitionScope -eq "Farm"}
#View Sharepoint Old 14 2010 Features
$spWEb.Features | select * |?{$_.Version -like "14*"}
#View Feature activated this month
$spWEb.Features | select * |?{$_.TimeActivated -gt (Get-Date).AddDays(-30)}

$spWeb.Fields | select Id,Title
$spWeb.Fields.Count
#Search for a field
#Add a Field location
$location = $spWeb.Fields| ?{$_.Title -like "Location"}
#View all FieldTypes
[System.Enum]::GetNames([Microsoft.SharePoint.SPFieldType])
if($location -eq $null)
{
$required = $false
$spWeb.Fields.Add("Location",[Microsoft.SharePoint.SPFieldType]::Geolocation,$required)
$spWeb.Update()
}
#View Fields of Type Text
$spWeb.Fields | ?{$_.Type -like "*Text*"}|select Title
$location = $spWeb.Fields["Location"]
#New content Type Location and add field to content Type
#$spWeb.ContentTypes["Holiday"].FieldLinks|select NAme
$spWeb.ContentTypes["Holiday"].FieldLinks.Add($location)
$spWeb.Update()

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$spWEb = Get-SpWeb -site "http://w15-sp"
$spWeb.FieldTypeDefinitionCollection
$spWeb.FieldTypeDefinitionCollection | select TypeName
#View count of field types
$spWeb.FieldTypeDefinitionCollection.Count
#View HTML field type
$spWeb.FieldTypeDefinitionCollection|?{$_.typeName -eq "HTML"}
#File dialog Post process id
$spWeb.FileDialogPostProcessorId
#View all files
$spWEb.Files
$spWEb.Files|select Url
$spWEb.FirstUniqueAncestor
$spWeb.FirstUniqueAncestorSecurableObject
$spWeb.FirstUniqueAncestorWeb
$spWEb.FirstUniqueRoleDefinitionWeb
$spWEb.Folders|select url

#Does the web have unique roles
$spWEb.HasUniqueRoleDefinitions
#Has unique security provider
$spWeb.HasExternalSecurityProvider
#Has unique permissions
$spWEb.HasUniquePerm
#Has unique role assignment
$spWEb.HasUniqueRoleAssignments
#Hide Site Contents Link setting
$spWEb.HideSiteContentsLink
#Non Host Header Url
$spWEb.NonHostHeaderUrl
#Overwrite transalation on change
$spWeb.OverwriteTranslationsOnChange
#Site ID
$spWeb.ID
#Include Supporting folders
$spWEb.IncludeSupportingFolders
#Indexed Proerty Keys
$spWEb.IndexedPropertyKeys
#IsAD Account Creation Mode
$spWeb.IsADAccountCreationMode


#$spWeb Properties
$spWeb.IsADEmailEnabled
#Is Web App Web
$spWeb.IsAppWeb
#MultiLanguage
$spWeb.IsMultilingual
#Is this Root Web
$spWeb.IsRootWeb
#What Language English 1033
$spWEb.Language
$SpWEb.Locale
#Last Item Modified Date
$spWEb.LastItemModifiedDate
#View All Lists
$spWeb.Lists|select Title
#View Hidden Lists
$spWeb.Lists |?{$_.Hidden -eq $true} |select Title
#View Lists recently created
#$spWeb.Lists | gm -MemberType Property |?{$_ -like "*created*"}
#If no lists created please use this cmdlet to add new list
#$spWEb.Lists.Add("fRUITS","Fruits list",[Microsoft.SharePoint.SPListTemplateType]::GenericList)
#$spWeb.Update()
$spWeb.Lists |?{$_.Created -gt (Get-Date).AddDays(-30)} |select
$spWeb.ListTemplates|select Name
$spWeb.MasterPageReferenceEnabled
#Master Url
$spWEb.MasterUrl
$spWeb.Modules
$spWeb.Name
$spWeb.Navigation
$spWeb.NoCrawl
$spWEb.NonHostHeaderUrl

$spWeb.OverwriteTranslationsOnChange
#Get Parent Web
$spWEb.ParentWeb
#Get Parent WEb ID
$spWeb.ParentWebId
#IS Parser Enabled
$spWeb.ParserEnabled
#spWEb Permissions
$spWeb.Permissions
#Is spWEb Portal Member
$spWEb.PortalMember
#Portal Name
$spWeb.PortalName
$spWeb.PortalSubscriptionUrl
$spWEb.PortalUrl
#Is Presence Enables
$spWEb.PresenceEnabled
#All Properties
$spWeb.Properties
                                                
<#vti_associategroups            7;3;3;6;5                                             
vti_associateownergroup        5                                                     
enabledhelpcollections         VGSEndUser;#FastEndUser;#SQLWSSAddIn                  
vti_defaultlanguage            en-us                                                 
taxonomyhiddenlist             026d3786-8536-437d-b5df-fff7b008d004                  
disabledhelpcollections                                                              
profileschemaversion           1                                                     
vti_associatemembergroup       7                                                     
vti_extenderversion            15.0.0.4420                                           
vti_associatevisitorgroup      6                                                     
vti_customuploadpage           /_layouts/15/UploadEx.aspx                            
vti_createdassociategroups     5;6;7                                                 
vti_mastercssfilecache         corev15app.css                                        
allowslistpolicy               True
#>
$spWeb.Properties["vti_associategroups"]
$spWeb.Properties["enabledhelpcollections"]
$spWeb.Properties["taxonomyhiddenlist"]
$spWeb.Properties["disabledhelpcollections"]
$spWeb.Properties["profileschemaversion"]
$spWeb.Properties["vti_associatemembergroup"]
$spWeb.Properties["vti_extenderversion"]
$spWeb.Properties["vti_associatevisitorgroup"]
$spWeb.Properties["vti_customuploadpage"]
$spWeb.Properties["vti_createdassociategroups"]
$spWeb.Properties["vti_mastercssfilecache"]
$spWeb.Properties["allowslistpolicy"]
$spWEb.Provisioned
$spWEb.PublicFolderRootUrl
$spWeb.PushNotificationSubscribers
$spWeb.QuickLaunchEnabled
$spWeb.RecycleBin
$spWEb.RecycleBinEnabled
$spWEb.RegionalSettings
#Installed Languages
$spWeb.RegionalSettings.InstalledLanguages
#View Locales
$spWEb.RegionalSettings.Locales
#RequestAccess
$spWEb.RequestAccessEmail
$spWEb.RequestAccessEnabled

$spWeb.RequireDynamicCanary
$spWeb.ReusableAcl
#Adding users
$spWeb.RoleAssignments.Groups
#View Permissions
$spWeb.RoleDefinitions| select BasePermissions,Hidden,Type,Id
$spWeb.Roles|select Name,Description
$spWeb.Roles
$spWEb.RootFolder
#welcmoe page
$spWeb.RootFolder.WelcomePage
#Audit Folder
$spWeb.RootFolder.Audit
$spWEb.RootFolder.Files
#Server Realtive Url
$spWEb.ServerRelativeUrl
#Can Site be saved as template
$spWeb.SaveSiteAsTemplateEnabled
#Can User see url structure
$spWEb.ShowUrlStructureForCurrentUser
#View Site
$spWeb.Site
#View Administrators
$spWEb.SiteAdministrators
#SiteClientTag
$spWeb.SiteClientTag
$spWeb.SiteGroups
$spWEb.SiteLogoDescription
$spWEb.SiteLogoUrl
#User Information List
$spWeb.SiteUserInfoList
#View all Users
$spUserList=$spWeb.SiteUserInfoList
$spUsers=$spUserList.Items
foreach($spUser in $spUsers)
{
$spUser| select ID,Title
}
#View all Site Users
$spWeb.SiteUsers
#View all solutions
$spWeb.Solutions
#UI Culture
$spWeb.SupportedUICultures
#Syndication Enabled?
$spWEb.SyndicationEnabled
#Theme URL
$spWeb.ThemeCssUrl
#Theme Css Usl
$spWeb.ThemedCssFolderUrl
#Theme Info
$spWeb.ThemeInfo
#Title
$spWeb.Title
#Title Resourse(Language)
$spWEb.TitleResource
#TreeView Enabled
$spWeb.TreeViewEnabled
#UI Culture
$spWeb.UICulture
#UIVersionConfigurationEnabled
$spWeb.UIVersionConfigurationEnabled
#Url of SPWeb
$spWeb.Url
#Custom Actions
$spWeb.UserCustomActions
#Is the user Site Admin
$spWeb.UserIsSiteAdmin
#Web Admin
$spWeb.UserIsWebAdmin
#UserResources
$spWEb.UserResources
#Users of the web
$spWeb.Users
#Add a user if not present
$spWeb.EnsureUser("contoso\administrator")
#IS the file available
$spWEb.GetFile("default.aspx")