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
 
 
Facebook
 
Technology FAQ
- Microsoft ebs security server configuration
- IIs7 on Windows server 2003
- How to Configure Failover Clusters With Win 2008 Server R2?
- Windows 2008 Network Load Balancing
- Windows Server 2008 - Group Policy Management - Remove Computer Management
- Remove shortcuts possibility in a web page or to put in favorite
- HTA Dynamic Drop Down List
- IIS host header and DNS
- VMware or MS Virtual Server?
- Adobe Acrobat 9 inserting tab pages
programming4us programming4us