Showing posts with label sharepoint. Show all posts
Showing posts with label sharepoint. Show all posts

Tuesday, December 4, 2018

SharePoint PowerShell 2013 Reference Guide

SharePoint PowerShell from 20331 and 20332

Managed Metadata

New-ADUser -SamAccountName SPSalesMMS -Name "SharePoint Sales MMS" -UserPrincipalName "SPSalesMMS@contoso.com" -AccountPassword (Read-host “enter password” -AsSecureString) -Path “OU=SharePoint,DC=Contoso,DC=com” -Enabled $true -PasswordNeverExpires $true -ChangePasswordAtLogon $false

New-SPManagedAccount

$AppPool = New-SPServiceApplicationPool -Name ContosoSalesMMSAppPool -Account SPSalesMMS@contoso.com

$MMS = New-SPMetadataServiceApplication -Name "Contoso Sales Managed Metadata" -ApplicationPool $AppPool -DatabaseName ContosoSalesMMS -HubUri http://sales.contoso.com

New-SPMetadataServiceApplicationProxy -Name "Contoso Sales Managed Metadata" -ServiceApplication $MMS –DefaultProxyGroup

State Service

$serviceApp = New-SPStateServiceApplication -Name "StateService-App"

New-SPStateServiceDatabase -Name "SS-Database" -ServiceApplication $serviceApp

New-SPStateServiceApplicationProxy -Name "StateService-App" -ServiceApplication $serviceApp -DefaultProxyGroup

Friday, December 22, 2017

SharePoint PowerShell 20339 Reference Guide

PowerShell SharePoint Code Examples

Here are examples inspired from the SharePoint Farm course 20339-1/20339-2

20339-1

Module 5: Installing and configuring SharePoint 2016

OOS Basic Setup

On OOS server …

New-OfficeWebAppsFarm -InternalURL “http://$env:COMPUTERNAME” –AllowHttp:$true –EditingEnabled:$true

On SharePoint server …

New-SPWOPIBinding -ServerName NYC-OOS –AllowHTTP:$true
Set-SPWOPIZone -Zone "internal-http"
$config = Get-SPSecurityTokenServiceConfig
$config.AllowOAuthOverHttp = $true
$config.Update()

Module 6 – Web Applications and Site Collections

Site Collection

New-SPContentDatabase -Name WSS_Content_TeamArchive -WebApplication http://teams.contoso.com

New-SPSite -Url "http://teams.contoso.com/team/archive" -ContentDatabase WSS_Content_TeamArchive -Name "Team Archive" -OwnerAlias CONTOSO\Administrator -Template "STS#0"


Module 7 – Service Applications

Managed Metadata

New-ADUser -SamAccountName SPSalesMMS -Name "SharePoint Sales MMS" -UserPrincipalName "SPSalesMMS@contoso.com" -AccountPassword (Read-host “enter password” -AsSecureString) -Path “OU=SharePoint,DC=Contoso,DC=com” -Enabled $true -PasswordNeverExpires $true -ChangePasswordAtLogon $false

New-SPManagedAccount

$AppPool = New-SPServiceApplicationPool -Name ContosoSalesMMSAppPool -Account SPSalesMMS@contoso.com

$MMS = New-SPMetadataServiceApplication -Name "Contoso Sales Managed Metadata" -ApplicationPool $AppPool -DatabaseName ContosoSalesMMS -HubUri http://sales.contoso.com

New-SPMetadataServiceApplicationProxy -Name "Contoso Sales Managed Metadata" -ServiceApplication $MMS -DefaultProxyGroup

Word Automation

New-ADUser -SamAccountName SPWordAutomation -Name "SP Word Automation" -UserPrincipalName "SPWordAutomation@contoso.com" -AccountPassword (Read-host “enter password” -AsSecureString) -Path “OU=SharePoint,DC=Contoso,DC=com” -Enabled $true -PasswordNeverExpires $true -ChangePasswordAtLogon $false

New-SPManagedAccount

$AppPool = New-SPServiceApplicationPool -Name ContosoWordAutomationAppPool -Account SPWordAutomation@contoso.com

$WCS = New-SPWordConversionServiceApplication -Name "Contoso Word Automation Service" -ApplicationPool $AppPool -DatabaseName ContosoWordAutomation

20339-2

Module 1

Farm configuration

New-SPConfigurationDatabase –DatabaseServer “ContosoDB” –DatabaseName “SharePoint_Config” –AdministrationContentDatabaseName “SharePoint Farm Content” –Passphrase (Read-Host –Prompt “Enter Farm PassPhrase” –AsSecureString) –FarmCredentials (Get-Credential –Message “Enter Farm Account Credential”) –LocalServerRole “Custom”

To create the ACL resources

Initialize-SPResourceSecurity

Install the required services

Install-SPService

Install the SharePoint features

Install-SPFeature -AllExistingFeatures

Create Central Administration

New-SPCentralAdministration -Port 50000 -WindowsAuthProvider NTLM

Install the Help Collection

Install-SPHelpCollection -All

Complete the installation of Central Administration

Install-SPApplicationContent

Create Default App Pool – Note that spservices account must be setup in AD

$appPoolCred = Get-Credential –Credential “contoso\spServices”

$saAppPoolAccount = New-SPManagedAccount -Credential $appPoolCred

$saAppPool = New-SPServiceApplicationPool -Name "SharePoint Web Services Default" -Account “contoso\spServices”

Search

$saAppPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services Default"

Start-SPEnterpriseSearchServiceInstance $env:COMPUTERNAME

Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $env:COMPUTERNAME

$searchServiceApp = New-SPEnterpriseSearchServiceApplication -Name “Search Service Application” -ApplicationPool $saAppPool -DatabaseServer “ContosoDB” -DatabaseName “Farm_SSA”

$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name “Search Service Application Proxy” -SearchApplication $searchServiceApp

[IO.Directory]::CreateDirectory(“c:\spSearchIndex”)

$clone = $searchServiceApp.ActiveTopology.Clone()

$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance –Local

New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance;

New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance;

New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance;

New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance;

New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance -RootDirectory “c:\spSearchIndex”;

New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance

$clone.Activate()


User Profile Service

$saAppPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services Default"

$upa = New-SPProfileServiceApplication –Name “User Profile Service” -ApplicationPool $saAppPool -ProfileDBName “Farm_UPA_Profile” -ProfileSyncDBServer “ContosoDB” -SocialDBName “Farm_UPA_Social” -SocialDBServer “ContosoDB” -ProfileSyncDBName “Farm_UPA_Sync” -ProfileDBServer “ContosoDB”

New-SPProfileServiceApplicationProxy -Name " User Profile Service Proxy" -ServiceApplication $upa –DefaultProxyGroup

Get-SPServiceInstance | where-object {$_.TypeName -eq “User Profile Service”} | Start-SPServiceInstance

Module 2

Office 365 Prerequisites

Create Default App Pool – Note that spservices account must be setup in AD

$appPoolCred = Get-Credential –Credential “contoso\spServices”

$saAppPoolAccount = New-SPManagedAccount -Credential $appPoolCred

$saAppPool = New-SPServiceApplicationPool -Name "SharePoint Web Services Default" -Account “contoso\spServices”

App Management

$appPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services Default"

$amsa = New-SPAppManagementServiceApplication -Name “App Management Service” -DatabaseName “Farm_App_Management” –ApplicationPool $appPool

$amsaProxy = New-SPAppManagementServiceApplicationProxy -Name " App Management Service Proxy" -UseDefaultProxyGroup -ServiceApplication $amsa

Get-SPServiceInstance | Where-Object {$_.TypeName -like "*App Management Service*"} | Start-SPServiceInstance

Subscription Service

$appPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services Default"

$SSSA = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPool -Name "Subscription Settings Service"

$sssaProxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $SSSA

$spInstances = Get-SPServiceInstance; $spInstances.Where{$_.TypeName -like "*Subscription Settings Service*"} | Start-SPServiceInstance


Appendix

State Service

$serviceApp = New-SPStateServiceApplication -Name "StateService-App"

New-SPStateServiceDatabase -Name "SS-Database" -ServiceApplication $serviceApp

New-SPStateServiceApplicationProxy -Name "StateService-App" -ServiceApplication $serviceApp -DefaultProxyGroup

Tuesday, June 27, 2017

SharePoint Remote PowerShell

Yes it is possible, Please follow the steps below.

On the client machine (the management server):

  • Enable-WSManCredSSP -Role Client -DelegateComputer * -Force
  • Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowFreshCredentials -Name WSMan -Value WSMAN/*

  • Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowFreshCredentialsDomain -Name WSMan -Value WSMAN/*

On the SharePoint server:

  • Enable-PSRemoting -Force

  • Enable-WSManCredSSP -Role Server -Force

Afterwards it is possible to connect to the server using PowerShell from your management server, using the following cmdlet:

  • Enter-PSSession SPServer -Authentication CredSSP -Credential DOMAIN\username
  • Add the SharePoint PowerShell SnapIn
  • Add-PSSnapIn Microsoft.SharePoint.PowerShell

To see if it works, run a simple SharePoint cmdlet:

Get-SPSite

PowerShell Remoting for SharePoint

Original Ref

https://blogs.msdn.microsoft.com/besidethepoint/2010/05/26/powershell-remoting-for-sharepoint/

Tuesday, October 4, 2016

SharePoint PowerShell

Update

DBATools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included
https://dbatools.io/

Github
https://github.com/sharepoint

Codeplex
http://www.codeplex.com/site/search?TagName=Sharepoint

Add Online Modules
http://sharepoint-tricks.com/install-update-uninstall-cmdlets-for-sharepoint-online

More from The Cloud Engineer

https://thecloudengineer.blogspot.com/2016/09/powershell-toolbox-for-sharepoint.html

Older News

Strange Error
http://sharepoint.stackexchange.com/questions/17247/spsite-allwebs-returns-error

PowerShell Articles from Mike Smith
http://sharepointpromag.com/author/michael-t-smith

http://sharepointpromag.com/sharepoint-2010/inventorying-sharepoint-using-powershell

http://sharepointpromag.com/sharepoint/windows-powershell-scripts-sharepoint-info-files-pagesweb-parts

http://sharepointpromag.com/sharepoint-2013/exploring-sharepoint-users-groups-and-security-using-powershell

http://sharepointpromag.com/sharepoint/exploring-and-inventorying-sharepoint-using-powershell-part-4-finding-and-resetting-custo

http://techtrainingnotes.blogspot.cz/2011/06/sharepoint-how-to-change-default-home.html

Creating Content Types (and Site Columns) with PowerShell

http://www.rbradbrook.co.uk/blog/2013/03/10/creating-content-types-and-site-columns-with-powershell/

Log Info
http://zimmergren.net/technical/sp-2010-find-error-messages-with-a-correlation-id-token-in-sharepoint-2010

General Info

Great Tool
http://www.sapien.com/software/powershell_studio

Great site with a ton of scripts
http://blogs.technet.com/b/onescript/p/sharepoint.aspx

Just found but untested

http://social.technet.microsoft.com/wiki/contents/articles/20692.sharepoint-get-set-and-copy-user-profile-properties-using-powershell.aspx

ISE http://thecloudengineer.blogspot.com/2011/10/create-ise-enabled-for-sharepoint.html

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

2013
Complete List - Index of Windows PowerShell cmdlets for SharePoint 2013
http://technet.microsoft.com/en-us/library/ff678226.aspx

2010
Complete List - Index of Windows PowerShell cmdlets for SharePoint 2010
http://technet.microsoft.com/en-us/library/ff678226(v=office.14).aspx

Great Reference to PowerShell in SharePoint 2010
http://technet.microsoft.com/en-us/library/ff678226.aspx

More from Powershell101
Users
http://powershell101.blogspot.com/2012/06/sharepint-users.html

Confirmed PS1 Examples

Enumerating SharePoint Permissions and Active Directory
New and improved http://briantjackett.com/archive/2013/07/01/powershell-script-to-enumerate-sharepoint-2010-or-2013-permissions-and.aspx

http://geekswithblogs.net/bjackett/archive/2009/04/24/the-power-of-powershell-and-sharepoint-enumerating-sharepoint-permissions-and.aspx

Capture and report on all SharePoint permissions through a site collection http://localgovernmentsharepoint.wordpress.com/2012/01/25/powershell-script-to-capture-and-report-on-all-sharepoint-permissions-through-a-site-collection/

Open Port Audit
http://gallery.technet.microsoft.com/Security-hardening-for-c425db1d

Potential Examples

Set AD changes needed for UPSA via powershell
http://blog.kuppens-switsers.net/2012/02/setting-replicating-directory-changes-using-powershell/

General Code from Engineers at PointBeyond
http://blog.pointbeyond.com/

Copy List
http://adicodes.com/copy-or-replace-list-items-in-powershell/#!

AD Lockout
http://mikefrobbins.com/2013/11/29/powershell-script-to-determine-what-device-is-locking-out-an-active-directory-user-account/

Move Site Collections
http://alinimer.com/2012/06/10/from-the-field-move-a-site-collection-to-new-content-db-with-new-managed-path/

Remove Unused Users
http://weblogs.asp.net/bsimser/archive/2013/02/12/powershell-tools-removing-orphaned-users-from-sharepoint.aspx

Long List of examples
http://powershellscripts.com/category.asp?cat=SharePoint

Adding users and claims to a site from PowerShell
http://blogs.msdn.com/b/brporter/archive/2010/12/02/adding-users-and-claims-to-a-site-from-powershell.aspx

Changing the Item-Level Permissions Settings for a Document Library requires PowerShell http://www.hersheytech.com/Blog/SharePoint/tabid/197/entryid/28/Default.aspx

Create a full site hierarchy
http://reality-tech.com/2012/03/07/scripts-to-create-scripts/

My Site
http://gallery.technet.microsoft.com/scriptcenter/Pre-Provision-SharePoint-ec781ee9

Tuesday, September 1, 2015

SharePoint Search Service Application PowerShell

 

Check the crawl status of all content sources in your SSA where SSA is search service application.

Get-SPEnterpriseSearchCrawlContentSource -SearchApplication "Search Service Application" | select Name, CrawlStatus | format-table –autosize

image

Total number of list items in a SharePoint Web Application

https://blogs.technet.microsoft.com/nishants/2012/05/04/total-number-of-list-items-in-a-sharepoint-web-application/

Tuesday, May 12, 2015

PowerShell Tip: #2 – SharePoint PowerShell

I love using the ISE to make building your scripts easier and using F5 and F8 keys to help run your scripts.  But I need to use the ISE on SharePoint. No problem just add the snap-in.  But wait, the snap-in goes away when you close the ISE.  No problem just add the SharePoint snap-in to your profile.

http://thecloudengineer.blogspot.com/2011/10/create-ise-enabled-for-sharepoint.html

Tuesday, December 3, 2013

Remove PowerShell Object

 

I was working with SharePoint and found an object that I needed to delete

image

NOTE that lega… is the friendly name.  Well not really.  On close examination appears that the name was corrupt.  The name was lega … with more info.

image

So using a where-object I gathered a couple of objects and saved as an array.

image

Then deleted the first object in the array using the name property.

image

HTH