IT tutorials
 
Applications Server
 

Microsoft Sharepoint 2013 : Some Sample PowerShell Scripts (part 1) - Creating Your SharePoint 2013 Farm with PowerShell, Creating Managed Accounts and Service Application Pools

4/7/2015 4:42:35 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Creating Your SharePoint 2013 Farm with PowerShell

The following script completely replaces using the Configuration Wizard to build your SharePoint 2013 farm:



# Add the SharePoint Snapin, in case PowerShell wasn't started with the Management
Shell
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

# Verify that PowerShell is running as an Admin
if ( -not ([Security.Principal.WindowsPrincipal] [Security.Principal.
WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]
"Administrator"))
{
Write-Output "This PowerShell prompt is not elevated"
write-output "Please start PowerShell with the Admin token and try again"
return
}

# Everything looks good. Let's build us a SharePoint farm

$domain = (Get-ChildItem env:userdomain).value
$tempfarmaccount = $domain.ToString() + '\sp_farm'
$tempsqlserver = (Get-ChildItem env:computername).value

$farmaccountname = Read-Host -Prompt "Enter Farm Account Name. Press Enter for
$tempfarmaccount"
If ($farmaccountname -eq "") {$farmaccountname = $tempfarmaccount}
$farmaccountpassword = Read-Host -Prompt "Enter Farm Account Password. Press Enter
for pass@word1"
If ($farmaccountpassword -eq "") {$farmaccountpassword = 'pass@word1'}
$farmpassphrase = Read-Host -Prompt "Enter Farm Passphrase. Press Enter for
pass@word1"
If ($farmpassphrase -eq "") {$farmpassphrase = 'pass@word1'}
$sqlserver = Read-Host -Prompt "Enter SQL Instance name. Press Enter for
$tempsqlserver"
If ($sqlserver -eq "") {$sqlserver = $tempsqlserver}

$password = ConvertTo-SecureString $farmaccountpassword -AsPlainText -Force
$farmaccount = New-Object system.management.automation.pscredential
$farmaccountname, $password

Write-Host "Using that information to build your SharePoint Farm"

New-SPConfigurationDatabase -DatabaseName SharePoint_Config -DatabaseServer
$sqlserver -AdministrationContentDatabaseName SharePoint_Admin_Content
-Passphrase (convertto-securestring $farmpassphrase -AsPlainText -Force)
-FarmCredentials $farmaccount

Write-Host "Config database built, now configuring local machine."

Install-SPHelpCollection -All
Initialize-SPResourceSecurity
Install-SPService
Install-SPFeature -AllExistingFeatures

Write-host "Creating Central Admin on port 10260"

New-SPCentralAdministration -Port 10260 -WindowsAuthProvider "NTLM"
Install-SPApplicationContent

As indicated by the comments, this script will work with SharePoint 2010 or SharePoint 2013. It employs not only several SharePoint cmdlets we have covered (those for which the noun starts with “SP”), but also many new PowerShell techniques such as asking for input, error control, and flow control. Once the script has completed successfully, your farm will be created, including Central Administration.

Creating Managed Accounts and Service Application Pools

When you’re configuring your farm, one of the first things you need to do is create the managed accounts and service app application pools your farm will use. The following PowerShell lines will do that:

# Create Managed Accounts
$password = ConvertTo-SecureString 'pass@word1' -AsPlainText -Force

# create sp_webapps
$account = New-Object system.management.automation.pscredential
'contoso\sp_webapps', $password
New-SPManagedAccount $account

# create sp_serviceapps
$account = New-Object system.management.automation.pscredential
'contoso\sp_serviceapps', $password
New-SPManagedAccount $account

# Create the Service App Pool
New-SPServiceApplicationPool -Name "Default SharePoint Service App Pool"
-Account contoso\sp_serviceapps
$apppool = Get-SPServiceApplicationPool "Default SharePoint Service App Pool"

Of course, you need to ensure that the usernames and passwords match those in your actual farm. The chances are pretty slim that your domain is Contoso.

 
Others
 
- VMware View 5 Architecture : Virtual (part 4) - Network, Storage
- VMware View 5 Architecture : Virtual (part 3) - vCenter Server
- VMware View 5 Architecture : Virtual (part 2) - VMware vSphere 5 Architecture, VMware vSphere 5, VMware ESXi, VMware vSphere 5
- VMware View 5 Architecture : Virtual (part 1) - Infrastructure Introduction
- VMware View 5 : Establishing a Performance Baseline (part 10)
- VMware View 5 : Establishing a Performance Baseline (part 9)
- VMware View 5 : Establishing a Performance Baseline (part 8)
- VMware View 5 : Establishing a Performance Baseline (part 7)
- VMware View 5 : Establishing a Performance Baseline (part 6)
- VMware View 5 : Establishing a Performance Baseline (part 5)
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us