Sharepoint Foundations 2013 Configuration Script

### Script Verified 26 August 2016 ###

## This script can be used with the FIM / MIM Preperation Script , The Preparation script is not required and to use this script with out the preparation script just Type "No" when prompted with with the question "Was the MIMPrep tool used to create Service Accounts Yes or No" ##

 

The Following Script can be used to configure SharePoint Foundation 2013 for use with the FIM / MIM Portal.

NOTE: The FIM / MIM Portal CAN NOT be installed with Claims Based Authentication which is configured by default when you first deploy SharePoint Foundations 2013 / SP1To run this script you may need to run from PowerShell as an Administrator as well as the Server mus

  1. On the Server you wish to configure SharePoint 2013 Foundations open up PowerShell as an Administrator
  2. Verify that the Server can load the Active Directory and SharePoint PowerShell Modules
  3. Verify that you have the Following information which you will be prompted for during the Configuration
    1. SharePoint Pool Service Account
    2. Primary Site Administrator Account
    3. Secondary Site Administrator Account
    4. Name of Base Site you wish to configure, this will also be used during the install of the FIM Portal
    5. The Port that this Site will be hosted on
  4. Its also important to note that you will be initially ask if the MIM Prep Tool was used at this time Type No and for verification type Y.

NOTE:

For all Prompts type "Yes" or "No" and for all Verification Type "1" for Yes or "2" for No.

When copying and pasting the following script be sure to verify that all " quotes copy correctly as well as the following "STS#0" is not converted with other characters.

 

### Script Updated 15 March 2015 ###
##This first line only needs to be run if you’re not running the SharePoint 2013 Management Console.
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
## to Verify if Microsoft.Sharepoint.Powershell has been added
# Get-PSSnapin
function Prompt-ForInput
{
Param($message)
$success = "n"
while($success -ne "" -and $success.ToLower() -ne "1")
{
$val = Read-Host $message
$success = Read-Host "You entered: $val. Is this correct? Enter the #1 for Yes or the # 2 for No"
}
return $val
}
##All sections highlighted in Pink are currently not in use
##This next block of code sets your variables the script will need to build your SharePoint Site
## Below you will need to know the following information
## NetBIOS Domain name
## The account that will be used run the actual website
## An account that will be used as a Farm Administrator
$Domain = $(Get-ADDomain).Name
$Prep = Prompt-ForInput "Was the MIMPrep tool used to create Service Accounts Yes or No"
$MIMPrep = $Prep.ToLower()

if($MIMPrep -eq "yes")
{
#### Import Feeder File
##########################################################################
#[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
Add-Type -assemblyName "System.Windows.Forms" #use this instead of loadwithpartialname
$dialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog
$dialog.AddExtension = $true
$dialog.Filter = 'CSV file (*.csv)|*.csv|All Files|*.*'
$dialog.Multiselect = $false
$dialog.FilterIndex = 0
$dialog.InitialDirectory = "$HOME\Documents"
$dialog.RestoreDirectory = $true
$dialog.ShowReadOnly = $true
$dialog.ReadOnlyChecked = $false
$dialog.Title = 'Select Pre Req CSV file'
$result = $dialog.ShowDialog()
if ($result -ne 'OK')
{
#return
Exit 1 #exit is more appropriate in this case and then you can also give a non-zero return code
}
$accts = Import-Csv $dialog.FileName
$svcFIMPool = ($accts | where-object{$_.variable -eq "MIMSPPool"}).SamAccountName
if(!$svcFIMPool)
{
$svcFIMPool = Prompt-ForInput "Enter the SharePoint Application Pool Service Account"
}
$FarmAdminUser = ($accts | where-object{$_.variable -eq "MIMAdmin"}).SamAccountName
if(!$FarmAdminUser)
{
$FarmAdminUser = Prompt-ForInput "Enter the Primary Site Collection Administrator Account"
}
$Site = "https://" + $($accts | where-object{$_.variable -eq "Site" -and $_.Type -eq "MIM"}).DisplayName
if(!$Site)
{
$Site = "https://" + $(Prompt-ForInput "Enter the site Url, Note: what ever is entered here will be used when Installing the FIM Portal")
}
$SecFarmAdmin = ($accts | where-object{$_.variable -eq "MIMSecAdmin"}).SamAccountName
if(!$SecFarmAdmin)
{
$SecFarmAdmin = Prompt-ForInput "Enter the Secondary Site Administrator Account"
}
$Port = ($accts | where-object{$_.variable -eq "Site"}).Value
if(!$Port)
{
$Port = Prompt-ForInput "Enter the Port Number to be set for the FIM Portal"
}
}
elseif($MIMPrep -eq "no")
{
# $svcFIMPool = "svcFIMSPPOOL"
$svcFIMPool = Prompt-ForInput "Enter the SharePoint Application Pool Service Account"
# $FarmAdminUser = "svcFIMAdmin"
$FarmAdminUser = Prompt-ForInput "Enter the Primary Site Collection Administrator Account"
# $Site = "FIMPortal"
$Site = "https://" + $(Prompt-ForInput "Enter the site Url, Note: what ever is entered here will be used when Installing the FIM Portal")
# $SecFarmAdmin = "Administrator"
$SecFarmAdmin = Prompt-ForInput "Enter the Secondary Site Administrator Account"
# $Port = 80
$Port = Prompt-ForInput "Enter the Port Number to be set for the FIM Portal"
}

##The next block of code sets the credentials being used to create the site
New-SPManagedAccount -Credential (Get-Credential -Message "FIMSPFPoolAccount" -UserName "$Domain\$svcFIMPool")
##A pop up will appear for you to type in the Password of the account that was set as the variable of $svcFIMPool
##You may need to correct the user name in the following format DOMAIN\ACCOUNT NAME
##Enter the Password in the window
##The next block of code will create the application pool
New-SPServiceApplicationPool -Name FIMSPFPool -Account $svcFIMPool
##This next block of code This creates a Web application that uses classic mode windows authentication
New-SPWebApplication -Name "FIM" -Url $site -Port $port -SecureSocketsLayer:$false -ApplicationPool "FIMSPFPool" -ApplicationPoolAccount (Get-SPManagedAccount $($svcFIMPool)) -AuthenticationMethod "Kerberos" -DatabaseName "FIM_SPF_Content"
##This block of code creates the creates the SP Site
New-SPSite -Name "FIM" -Url $Site -CompatibilityLevel 14 -Template "STS#0" -OwnerAlias $FarmAdminUser
##This next block of code sets Secondary Site Administrator
Set-SPSite -Identity $Site -SecondaryOwnerAlias "$Domain\$SecFarmAdmin"
##This block of code disables server side view state which is required for FIM
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$contentService.ViewStateOnServer = $false
$contentService.Update()

##This last block of code disables self-service upgrade to 2013 Experience mode
#2013 Experience mode is not supported by FIM
##Old Block of Code $SPSite = SPSite("https://FIMPortal")
$SPSite = Get-SPSite $Site

$SPSite.AllowSelfServiceUpgrade = $false

 

 

## https://blogs.msdn.com/connector_space ##

 

Troubleshooting notes:

In case your having issues running this script verify the following

1. Active Directory Module is installed

2. Verify that you have copied the text correctly and verify that all quotes are correct you may need to replace the quotes.

3.The following line often does not copy over correctly

New-SPSite -Name "FIM" -Url $Site -CompatibilityLevel 14 -Template "STS#0" -OwnerAlias $FarmAdminUser