Installation

The tool was unable to install Application Server Role, Web Server (IIS) Role

Posted on Updated on

For my experience, this error may happen in virtualized environments, manly in Azure.

There are many workarounds, but I,ll suggest this one:

Off-line Install

  1. Copy the sxs file from sources “Binaries”
  2. Run this PowerShell script (assuming D:\sxs), change last line
Import-Module ServerManager `
Add-WindowsFeature `
	Net-Framework-Features, `
	Web-Server,Web-WebServer, `
	Web-Common-Http,Web-Static-Content, `
	Web-Default-Doc,Web-Dir-Browsing, `
	Web-Http-Errors,Web-App-Dev, `
	Web-Asp-Net, `
	Web-Net-Ext, `
	Web-ISAPI-Ext, `
	Web-ISAPI-Filter, `
	Web-Health, `
	Web-Http-Logging, `
	Web-Log-Libraries, `
	Web-Request-Monitor, `
	Web-Http-Tracing, `
	Web-Security, `
	Web-Basic-Auth, `
	Web-Windows-Auth, `
	Web-Filtering, `
	Web-Digest-Auth, `
	Web-Performance, `
	Web-Stat-Compression, `
	Web-Dyn-Compression, `
	Web-Mgmt-Tools, `
	Web-Mgmt-Console, `
	Web-Mgmt-Compat, `
	Web-Metabase, `
	Application-Server, `
	AS-Web-Support,
	AS-TCP-Port-Sharing, `
	AS-WAS-Support, `
	AS-HTTP-Activation, `
	AS-TCP-Activation, `
	AS-Named-Pipes, `
	AS-Net-Framework, `
	WAS,WAS-Process-Model, `
	WAS-NET-Environment, `
	WAS-Config-APIs, `
	Web-Lgcy-Scripting, `
	Windows-Identity-Foundation, `
	Server-Media-Foundation, `
	Xps-Viewer -Source D:sxs

2. Download Files in a PC with internet

#***************************************************************************************
# Written by Craig Lussier - http://craiglussier.com
#
# This script downloads SharePoint 2013 Prerequisites
#   
# -Only run this script on Windows Server 2012 (RTM, either Standard or Datacenter)
# -Do not run this script on a Windows Server 2008 R2 SP1 Server!
# ---These are the Prerequisites for Windows Server 2012
# -Run this script as a local server Administrator
# -Run PowerShell as Administrator
#
# Don't forget to: Set-ExecutionPolicy RemoteSigned
# If you have not done so already within you Windows Server 2012 server
#****************************************************************************************
param([string] $SharePoint2013Path = $(Read-Host -Prompt "Please enter the directory path to where you wish to save the SharePoint 2013 Prerequisite files.")) 
 
# Import Required Modules
Import-Module BitsTransfer 


# Specify download url's for SharePoint 2013 prerequisites
$DownloadUrls = (
            "http://download.microsoft.com/download/9/1/3/9138773A-505D-43E2-AC08-9A77E1E0490B/1033/x64/sqlncli.msi", # Microsoft SQL Server 2008 R2 SP1 Native Client
            "http://download.microsoft.com/download/E/0/0/E0060D8F-2354-4871-9596-DC78538799CC/Synchronization.msi", # Microsoft Sync Framework Runtime v1.0 SP1 (x64)
            "http://download.microsoft.com/download/A/6/7/A678AB47-496B-4907-B3D4-0A2D280A13C0/WindowsServerAppFabricSetup_x64.exe", # Windows Server App Fabric
            "http://download.microsoft.com/download/7/B/5/7B51D8D1-20FD-4BF0-87C7-4714F5A1C313/AppFabric1.1-RTM-KB2671763-x64-ENU.exe", # Cumulative Update Package 1 for Microsoft AppFabric 1.1 for Windows Server (KB2671763)
            "http://download.microsoft.com/download/D/7/2/D72FD747-69B6-40B7-875B-C2B40A6B2BDD/Windows6.1-KB974405-x64.msu", #Windows Identity Foundation (KB974405)
            "http://download.microsoft.com/download/0/1/D/01D06854-CA0C-46F1-ADBA-EBF86010DCC6/rtm/MicrosoftIdentityExtensions-64.msi", # Microsoft Identity Extensions
            "http://download.microsoft.com/download/9/1/D/91DA8796-BE1D-46AF-8489-663AB7811517/setup_msipc_x64.msi", # Microsoft Information Protection and Control Client
            "http://download.microsoft.com/download/8/F/9/8F93DBBD-896B-4760-AC81-646F61363A6D/WcfDataServices.exe" # Microsoft WCF Data Services 5.0
                ) 


function DownLoadPreRequisites() 
{ 

    Write-Host ""
    Write-Host "====================================================================="
    Write-Host "      Downloading SharePoint 2013 Prerequisites Please wait..." 
    Write-Host "====================================================================="
     
    $ReturnCode = 0 
 
    foreach ($DownLoadUrl in $DownloadUrls) 
    { 
        ## Get the file name based on the portion of the URL after the last slash 
        $FileName = $DownLoadUrl.Split('/')[-1] 
        Try 
        { 
            ## Check if destination file already exists 
            If (!(Test-Path "$SharePoint2013Path\$FileName")) 
            { 
                ## Begin download 
                Start-BitsTransfer -Source $DownLoadUrl -Destination $SharePoint2013Path\$fileName -DisplayName "Downloading `'$FileName`' to $SharePoint2013Path" -Priority High -Description "From $DownLoadUrl..." -ErrorVariable err 
                If ($err) {Throw ""} 
            } 
            Else 
            { 
                Write-Host " - File $FileName already exists, skipping..." 
            } 
        } 
        Catch 
        { 
            $ReturnCode = -1 
            Write-Warning " - An error occurred downloading `'$FileName`'" 
            Write-Error $_ 
            break 
        } 
    } 
    Write-Host " - Done downloading Prerequisites required for SharePoint 2013" 
     
    return $ReturnCode 
} 


 

function CheckProvidedDownloadPath()
{


    $ReturnCode = 0

    Try 
    { 
        # Check if destination path exists 
        If (Test-Path $SharePoint2013Path) 
        { 
           # Remove trailing slash if it is present
           $script:SharePoint2013Path = $SharePoint2013Path.TrimEnd('\')
       $ReturnCode = 0
        }
        Else {

       $ReturnCode = -1
           Write-Host ""
       Write-Warning "Your specified download path does not exist. Please verify your download path then run this script again."
           Write-Host ""
        } 


    } 
    Catch 
    { 
         $ReturnCode = -1 
         Write-Warning "An error has occurred when checking your specified download path" 
         Write-Error $_ 
         break 
    }     
    
    return $ReturnCode 

}


 
function DownloadPreReqs() 
{ 

    $rc = 0 
    
    $rc = CheckProvidedDownloadPath  

    # Download Pre-Reqs  
    if($rc -ne -1) 
    { 
        $rc = DownLoadPreRequisites 
    } 
     

    if($rc -ne -1)
    {

        Write-Host ""
        Write-Host "Script execution is now complete!"
        Write-Host ""
    }


} 

DownloadPreReqs

3. Install Pre files (Servers)

#***************************************************************************************
# Written by Craig Lussier - http://craiglussier.com
#
# This script downloads and instals SharePoint 2013 Prerequisites
#  
# -Only run this script on Windows Server 2012 (RTM, either Standard or Datacenter)
# -Do not run this script on a Windows Server 2008 R2 SP1 Server!
# ---These are the Prerequisites for Windows Server 2012
# -Run this script as a local server Administrator
# -Run PowerShell as Administrator
# 
# IMPORTANT NOTES:
# -The $SharePoint2013Path is the path to your SharePoint 2013 installation media
# -This script utilizes the PrerequisiteInstaller.exe in your SharePoint 2013 media
# -The script points to your $SharePoint2013Path\PrerequisiteInstallerFiles directory.
# ---BE SURE TO COPY THE PREREQ FILES INTO THIS DIRECTORY IF THEY ARE NOT ALREADY THERE FROM THE Download-SP2013PreReqFiles.ps1 script
#
# Don't forget to: Set-ExecutionPolicy RemoteSigned
# If you have not done so already within you Windows Server 2012 server
#****************************************************************************************
param([string] $SharePoint2013Path = $(Read-Host -Prompt "Please enter the directory path to where your SharePoint 2013 installation files exist.")) 
 

 
function InstallPreReqFiles() 
{ 

    $ReturnCode = 0

    Write-Host ""
    Write-Host "====================================================================="
    Write-Host "Installing Prerequisites required for SharePoint 2013" 
    Write-Host ""
    Write-Host "This uses the supported installing offline method"
    Write-Host ""
    Write-Host "If you have not installed the necessary Roles/Features"
    Write-Host "this will occur at this time."
    Write-Host "=====================================================================" 
     
     
        Try 
        { 
        

             Start-Process "$SharePoint2013Path\PrerequisiteInstaller.exe" -ArgumentList "`
                                                                                             /SQLNCli:`"$SharePoint2013Path\PrerequisiteInstallerFiles\sqlncli.msi`" `
                                                                                             /IDFX:`"$SharePoint2013Path\PrerequisiteInstallerFiles\Windows6.1-KB974405-x64.msu`" `
                                                                                             /IDFX11:`"$SharePoint2013Path\PrerequisiteInstallerFiles\MicrosoftIdentityExtensions-64.msi`" `
                                                                                             /Sync:`"$SharePoint2013Path\PrerequisiteInstallerFiles\Synchronization.msi`" `
                                                                                             /AppFabric:`"$SharePoint2013Path\PrerequisiteInstallerFiles\WindowsServerAppFabricSetup_x64.exe`" `
                                                                                             /KB2671763:`"$SharePoint2013Path\PrerequisiteInstallerFiles\AppFabric1.1-RTM-KB2671763-x64-ENU.exe`" `                                                                                             
                                                                                             /MSIPCClient:`"$SharePoint2013Path\PrerequisiteInstallerFiles\setup_msipc_x64.msi`" `
                                                                                             /WCFDataServices:`"$SharePoint2013Path\PrerequisiteInstallerFiles\WcfDataServices.exe`""
        } 
        Catch 
        { 
            $ReturnCode = -1 
            Write-Error $_ 
            break 
        }     
 
    return $ReturnCode 
} 
 
function CheckProvidedSharePoint2013Path()
{


    $ReturnCode = 0

    Try 
    { 
        # Check if destination path exists 
        If (Test-Path $SharePoint2013Path) 
        { 
           # Remove trailing slash if it is present
           $script:SharePoint2013Path = $SharePoint2013Path.TrimEnd('\')
       $ReturnCode = 0
        }
        Else {

       $ReturnCode = -1
           Write-Host ""
       Write-Warning "Your specified download path does not exist. Please verify your download path then run this script again."
           Write-Host ""
        } 


    } 
    Catch 
    { 
         $ReturnCode = -1 
         Write-Warning "An error has occurred when checking your specified download path" 
         Write-Error $_ 
         break 
    }     
    
    return $ReturnCode 

}


 
function InstallPreReqs() 
{ 

    $rc = 0 
    
    $rc = CheckProvidedSharePoint2013Path  

     
    # Install the Pre-Reqs 
    if($rc -ne -1) 
    { 
       $rc = InstallPreReqFiles 
    } 

    if($rc -ne -1)
    {

        Write-Host ""
        Write-Host "Script execution is now complete!"
        Write-Host ""
    }


} 

InstallPreReqs

4. Install Roles (Servers)

#***************************************************************************************
# Written by Craig Lussier - http://craiglussier.com
#
# This script installs SharePoint 2013 Roles/Features for Windows Server 2012
#  
# -Only run this script on Windows Server 2012 (RTM, either Standard or Datacenter)
# -If you are running this script 'offline' have your Windows Server 2012 installation
#  Media mounted/copied to this machine. You can also use a network UNC path.
# -Do not run this script on a Windows Server 2008 R2 SP1 Server!
# ---These are the Prerequisites for Windows Server 2012
# -Run this script as a local server Administrator
# -Run PowerShell as Administrator
#
# Don't forget to: Set-ExecutionPolicy RemoteSigned
# If you have not done so already within you Windows Server 2012 server 
#****************************************************************************************
# Import Required Module
Import-Module ServerManager

function AddWindowsFeatures() 
{ 
    Write-Host "==================================================================================="
    Write-Host "Install required Windows Roles/Features for SharePoint 2013 on Windows Server 2012"
    Write-Host ""
    Write-Host "Note: You'll receive prompt to restart your server when the"
    Write-Host "      Windows Server 2012 Role/Feature installation is complete."
    Write-Host "==================================================================================="        
     
      
    # Note: You can use the Get-WindowsFeature cmdlet (its in the ServerManager module) 
    #       to get a listing of all features and roles.
    $WindowsFeatures = @(
            "Net-Framework-Features",
            "Web-Server",
            "Web-WebServer",
            "Web-Common-Http",
            "Web-Static-Content",
            "Web-Default-Doc",
            "Web-Dir-Browsing",
            "Web-Http-Errors",
            "Web-App-Dev",
            "Web-Asp-Net",
            "Web-Net-Ext",
            "Web-ISAPI-Ext",
            "Web-ISAPI-Filter",
            "Web-Health",
            "Web-Http-Logging",
            "Web-Log-Libraries",
            "Web-Request-Monitor",
            "Web-Http-Tracing",
            "Web-Security",
            "Web-Basic-Auth",
            "Web-Windows-Auth",
            "Web-Filtering",
            "Web-Digest-Auth",
            "Web-Performance",
            "Web-Stat-Compression",
            "Web-Dyn-Compression",
            "Web-Mgmt-Tools",
            "Web-Mgmt-Console",
            "Web-Mgmt-Compat",
            "Web-Metabase",
            "Application-Server",
            "AS-Web-Support",
            "AS-TCP-Port-Sharing",
            "AS-WAS-Support",
            "AS-HTTP-Activation",
            "AS-TCP-Activation",
            "AS-Named-Pipes",
            "AS-Net-Framework",
            "WAS",
            "WAS-Process-Model",
            "WAS-NET-Environment",
            "WAS-Config-APIs",
            "Web-Lgcy-Scripting",
            "Windows-Identity-Foundation",
            "Server-Media-Foundation",
            "Xps-Viewer"
    )


    #Prompt To Start Role/Feature Installation
    $title = "Do you wish to perform an online or offline installation?"
    $message = "Please ensure that you have read and understand the instructions located at http://gallery.technet.microsoft.com/DownloadInstall-SharePoint-e6df9eb8. 'Online' means Windows Server 2012 is connected to the Internet and Windows Update is used to download supporting files, Offline means Windows Server 2012 is not connected to the Internet and you have your Windows Server 2012 installation media mounted/copied to this server to install supporting files."

    $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Online", `
       "Uses Windows Update to download and install necessary components related to .NET 3.5 feature (NET-Framework-Core)"

    $no = New-Object System.Management.Automation.Host.ChoiceDescription "O&ffline", `
           "Uses Windows Server 2012 media to install necessary components related to .NET 3.5 feature (NET-Framework-Core)"

    $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)

    $result = $host.ui.PromptForChoice($title, $message, $options, 0) 

    $windowsServer2012MediaPath = ""
    Write-Host ""

    switch ($result)
    {
        
        0 {"You will be using Windows Update to download the necessary components to install features related to .NET 3.5. This will extend the duration of your Role/Feature installation."}
        1 {$windowsServer2012MediaPath = $(Read-Host -Prompt "Please enter the directory pointing to the directory of your Windows Server 2012 installation media. Fore example, D:\sources\sxs")}
    }
    Write-Host ""


    Try 
    { 
    # Create PowerShell to execute 

        $source = "" 

        if($windowsServer2012MediaPath -ne "") {
           $source = ' -source ' + $windowsServer2012MediaPath
        }
        

        $myCommand = 'Add-WindowsFeature ' + [string]::join(",",$WindowsFeatures) + $source

        # Execute $myCommand
        $operation = Invoke-Expression $myCommand    

        if ($operation.RestartNeeded -eq "Yes") { 
        
             #Prompt User for Restart
       $title = "Restart your server now?"
       $message = "Would you like to restart your server now? It is required to complete the Windows Role/Feature Installation."

       $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", `
             "Restarts your Windows Server 2012 server now to complete the Role/Feature installation."

       $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", `
        "Does not restart your server now... But you should..."

       $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)

       $result = $host.ui.PromptForChoice($title, $message, $options, 0) 

       switch ($result)
       {
            0 {Restart-Computer;}
            1 {"Your server will not restart at this time. Before installing the Pre-requisite files, restart your computer."}
       }


        }

    } 
    Catch 
    { 
        Write-Warning "Error when Adding Windows Features. Error details are below:" 
        Write-Error $_ 
        break 
    } 
      
} 

AddWindowsFeatures

References:

REF1 – http://kx.cloudingenium.com/
REF2 – https://gallery.technet.microsoft.com 

Next Steps:

https://autospinstaller.com/

Object cache user accounts in SharePoint Server 2013

Posted on Updated on

From TechNet we can read

“The object cache stores properties about items in SharePoint Server 2013. Items in this cache are used by the publishing feature when it renders web pages. The goals of the object cache are to reduce the load on the computer on which SQL Server is running, and to improve request latency and throughput. The object cache makes its queries as one of two out-of-box user accounts: the Portal Super User and the Portal Super Reader. These user accounts must be properly configured to ensure that the object cache works correctly. The Portal Super User account must be an account that has Full Control access to the web application. The Portal Super Reader account must be an account that has Full Read access to the web application.”

The problem is that assigning accounts like SuperUser and SuperReader to your Web Applications is not enough, you need to give Full Control to SuperUser and Full Read to SuperReader, so you can have everything working and well. Sometimes scripts stop running and sites become inaccessible because bad configuration off Cache Accounts’.

This is my complete script to set the cached accounts according:

cls
$ver = $host | select version
if ($ver.Version.Major -gt 1)  {$Host.Runspace.ThreadOptions = "ReuseThread"}
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Import-Module WebAdministration -ErrorAction SilentlyContinue
 
## SharePoint DLL
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 
$wa = Get-SPWebApplication -Identity "http://yoursite.corp"
$SuperUserAcc = "i:0#.w|DOMAIN\SP_YourSuperUser"
$SuperReaderAcc = "i:0#.w|DOMAIN\SP_YourSuperReader"
Function Set-WebAppUserPolicy($wa, $userName, $displayName, $perm) 
{
    [Microsoft.SharePoint.Administration.SPPolicyCollection]$policies = $wa.Policies
    [Microsoft.SharePoint.Administration.SPPolicy]$policy = $policies.Add($userName, $displayName)
    [Microsoft.SharePoint.Administration.SPPolicyRole]$policyRole = $wa.PolicyRoles | where {$_.Name -eq $perm}
    If ($policyRole -ne $null) {
        $policy.PolicyRoleBindings.Add($policyRole)
    }
    $wa.Update()
}

$wa.Properties["portalsuperuseraccount"] = $SuperUserAcc
Set-WebAppUserPolicy $wa $SuperUserAcc "Super User (Object Cache)" "Full Control"
$wa.Properties["portalsuperreaderaccount"] = $SuperReaderAcc
Set-WebAppUserPolicy $wa $SuperReaderAcc "Super Reader (Object Cache)" "Full Read"
$wa.Update() 

Install and Configure SharePoint 2013 with Powershell

Posted on Updated on

This article intent to demonstrate how to automate Configuration and Installation in a DEV Environment

The Source 

Codeplex Tools for installing and configuring SharePoint 2013

Tools

  1. AutoSPInstaller v3
  2. AutoSPInstallerGUI

The secret is follow a sequence:

  1. Copy SharePoint Binaries, Service Pack’s and Language Packs to folder structure
  2. Configure your XML File with AutoSPInstallerGUI
    1. Configure Installation
    2. Configure Farm
      1. Create your Portal App
      2. Create MySites App
    3. Configure Service Applications
  3. Choose to stop the script after install binaries

Copy SharePoint Binaries, Service Pack’s and Language Packs to folder structure

 image  

image

image

Use the correct language code, in my case folder “pt-pt”

Configure your XML File with AutoSPInstallerGUI

Download tools for a folder and open “AutoSPInstallerInput.xml”

image

image

image

image

image

Configure Services

Bellow is my script that will install and configure

  1. MMS
  2. UPS
  3. Search
  4. State
  5. Usage and Health
  6. Secure Store
  7. Subscription Service
  8. App Management
  9. Work Management
  10. Machine Transaction
  11. PDF MIME Type Configure

Result

image

Script

Get here: http://wp.me/a4C9Xq-2e