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")







No comments:

Post a Comment