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.


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
$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')
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
$svcFIMPool = Prompt-ForInput "Enter the SharePoint Application Pool Service Account"
$FarmAdminUser = ($accts | where-object{$_.variable -eq "MIMAdmin"}).SamAccountName
$FarmAdminUser = Prompt-ForInput "Enter the Primary Site Collection Administrator Account"
$Site = "http://" + $($accts | where-object{$_.variable -eq "Site" -and $_.Type -eq "MIM"}).DisplayName
$Site = "http://" + $(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
$SecFarmAdmin = Prompt-ForInput "Enter the Secondary Site Administrator Account"
$Port = ($accts | where-object{$_.variable -eq "Site"}).Value
$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 = "http://" + $(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

##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("http://FIMPortal")
$SPSite = Get-SPSite $Site

$SPSite.AllowSelfServiceUpgrade = $false



## ##


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

Comments (6)
  1. Kerly says:

    Hi Anthony, I am planning to use SharePoint Foundation 2016 on Window 2016 OS (with SQL2016). Can this configuration script be used for SharePoint Foundation 2016 prep prior to setting up MIM2016SP1?

    1. As soon as I can I will test this out, I been working on some new stuff but I am definitely curious. If you try it before I post an update let me know

  2. @Robert is correct, the script was written with that idea that most people didn’t like typing in DOMAIN\ACCOUNT as far as not entering http:// this is interesting because I never would have thought that anyone would, not saying your wrong to do so more as an amateur developer I need to learn to write code / scripts to accommodate all scenarios thanks for pointing this out

  3. Robert Rust says:

    A couple of items that hung me up (some longer than others):

    1) It may be obvious to some more familiar with what the script does, but when prompted for the account, domain name isn’t needed (I was putting mine in … domain\username)
    2) Looking through the code the first few times, I missed that http:// was being prepended to the site URL, so that’s not needed in the user input either
    3) Likely because I was using a non-default port (82), you’ll need to include nonstandard ports in the site URL when using the SPSite cmdlets. I took the object that’s returned from the New-SPWebApplication cmdlet and used its url property in my SPSite cmdlets further down the list to avoid that problem.

    Overall this was very helpful. If I had more time, I’d add some error handling and make it easier to bail out of the script (prior to the SP calls of course).


  4. flyguybob says:

    FIMDevil –
    Dude! This is awesome! It saved quite a bit of time and, with the previous instructions, allowed me to “nail it!” in 4 1/2 hours. Prior to that I had been working on the installation over 3 days, struggling particularly with the prerequisite installation on Windows Server 2012 R2. One of my colleagues was able to follow this, particularly prerequisite documents 6, 7, and 8 to get this installed.

    There was a small issue where my computer decided to change the ” to a ?, possibly because it did not like that different style of quote when I pasted it into Notepad and into ISE. Powershell likes ” but not ” or “, apparently. It reminds me of a cat that will eat stinky seafood cat food but won’t touch the shrimp in it, using her claw to drag it off the plate and throw it on the floor in disdain and discust. Contemptful kitties! …I digress…

    This was one of the lines affected as an example:
    New-SPSite -Name “FIM” -Url $Site -CompatibilityLevel 14 -Template “STS#0″ -OwnerAlias $FarmAdminUser

    Once I put the quotes in place everything worked magically.

    Thank you and Kristopher for publishing the install and configuration documents to the world. Thanks for the script. One day PowerShell and BASH on Windows will automate us infrastructure geeks out of a job.

  5. Recently Updated to clarify accounts needed during prompts.

Comments are closed.

Skip to main content