• AutoSPInstaller for beginners

    I love to write blog posts for beginners. Maybe because, I always feel happy and energized when I stumble upon a helpful blog post when I am learning a new subject. In this post, I will introduce you to AutoSPInstaller (http://autospinstaller.codeplex.com/ ), the framework for installing and configuring SharePoint using automated scripts. It is a great toolkit - whether for a test farm or a high-end production environment - AutoSPInstaller can save you time, effort, and bring consistency and predictability to your SharePoint works. Let's get started.

    So what is AutoSPInstaller? it is a set of scripts, xml configuration files, and batch files to automate the installation and configuration of a SharePoint farm. From the AutoSPInstaller codeplex page:

    "This project consists of PowerShell scripts, an XML input file, and a standard windows batch file (to kick off the process) which together provide a quick and near-unattended installation and initial configuration (Service Apps, My Sites) of Microsoft SharePoint Server 2010/2013. Works on Windows 2008 (though I hardly test on that OS these days), 2008 R2 and Windows 2012 (x64 only of course).

    Perfect for repeated Virtual Machine-based installs/tear-downs, etc., but also great for production installs where you want to guarantee consistency and minimize data entry glitches. The immediate value is for installing and configuring the first/only server in a farm, but also supports using either server-specific input files or a single, all-encompassing input file for running the script on all farm servers (with parameters - e.g. for the service apps - set according to your desired topology).

    "But doesn't SharePoint 2010 have a nice wizard now that does all this for me??" - Yes, and it's a huge improvement over what was available in MOSS 2007. However if you've ever seen the 'DBA nightmare' left behind on your SQL server after the Farm Configuration Wizard has completed (GUID'ed databases with inconsistent naming, etc.):"


    Two other tools support AutoSPInstaller which are the following:

    - AutoSPSourceBuilder: which is a "utility for building a SharePoint 2010 / 2013 install source including prerequisites, service packs, language packs & cumulative updates". See http://autospsourcebuilder.codeplex.com/

    - AutoSPInstallerGUI: which is a light-weight desktop tool used to edit the input configuration file of AutoSPInstaller. See https://autospinstallergui.codeplex.com/

    So how does AutoSPInstaller works:

    1. You download the AutoSPInstaller package and extract it. You get one folder "SP" and in this folder there are 3 subfolders:

    • AutoSPInstaller, which has the scripts
    • 2010, a folder where you place your SharePoint 2010 prerequisites, core binaries, and service packs, CUs, etc... (in case you are installing 2010)
    • 2013, a folder where you place your SharePoint 2013 prerequisites, core binaries, and service packs, CUs, etc... (in case you are installing 2013)

    2. You place the SharePoint prerequisites, core binaries, SPs, and CUs, etc... in their respective subfolders in the master folder of the version of choice (see above). Note: use AutoSPSourceBuilder to slipstream - build the source files.

    3. You create all the prerequisite service accounts and install/configure SQL Server.

    4. You modify the input file, which is AutoSPInstallerInput according to the desired topology, service accounts, web applications, service apps, etc...

    5. You run the batch file AutoSPInstallerLaunch.bat and it works like magic. AutoSPInstaller will execute the file AutoSPInstallerMain and the referenced ps1 files and build/configure the farm.

    Now, I have simplified the whole process in a few steps, but make sure to follow the SharePoint setup/configuration best practices and prepare everything needed for the farm in advance.

    The AutoSPInstaller team did a great job and most of the problems/glitches you will run into are listed in the tool's codeplex site. This is an awesome tool and I recommend it for your SharePoint deployments.

    Good luck!

    Yousef

  • Configuring SharePoint 2013 Search Topology

     

    Introduction

    When creating the Search Service application , a default topology will be built automatically where all Search components are assigned to the server which is running the Central Administration, in multi servers farm scenario you need to change this topology , the only available way currently is through PowerShell which will provide more flexibility in configuring the topology, (you can NOT modify the topology through UI like you used to do with SharePoint 2010)

     

     

    Sample Topology

    I will guide you in this post on how to configure 5 servers as the following:

    • 3 front servers running the Query Processing component to handle search query requests from users, the query processing components will be located in the WFE servers.
    • 2 backend servers servers running the rest of Search components , The rest of search components will be located in the Application servers.
    • We will configure the below topology to have all Search components high available (no single point of failure for any components) , even the index partition will be replicated to the other server (replica)

    you can refer to the below diagram to have better understanding for the topology we are about to configure:

    clip_image001

     

    Before you start

    • make sure that the current user who is going to execute the power shell is added as admin to Search service application

    image 

    • Make sure to run the below Powershell commands on the server that is hosting the Central Administration
    • from Central administration – Search Administration page , make sure the index files are empty , Searchable items appears as 0

    now let us start by opening the powerShell on the server running the Central administration, make sure to execute all the below commands in the same PowerShell screen, but I have divided them in  below to make them more readable:

    where SPAPP-SRV1, SPAPP-SRV2, SPWF-SRV1, SPWF-SRV2, SPWF-SRV3  are the server names

    Prepare the topology variables

    $hostApp1 = Get-SPEnterpriseSearchServiceInstance -Identity "SPAPP-SRV1"  

    $hostApp2 = Get-SPEnterpriseSearchServiceInstance -Identity "SPAPP-SRV2"

    $hostWF1 = Get-SPEnterpriseSearchServiceInstance -Identity "SPWF-SRV1"

    $hostWF2 = Get-SPEnterpriseSearchServiceInstance -Identity "SPWF-SRV2"

    $hostWF3 = Get-SPEnterpriseSearchServiceInstance -Identity "SPWF-SRV3"

    Start-SPEnterpriseSearchServiceInstance -Identity $hostApp1

    Start-SPEnterpriseSearchServiceInstance -Identity $hostApp2

    Start-SPEnterpriseSearchServiceInstance -Identity $hostWF1

    Start-SPEnterpriseSearchServiceInstance -Identity $hostWF2

    Start-SPEnterpriseSearchServiceInstance -Identity $hostWF3

     

    Get services status

    Get Search Service Instance status (started or stopped) after running the above commands

    Get-SPEnterpriseSearchServiceInstance -Identity $hostApp1
    Get-SPEnterpriseSearchServiceInstance -Identity $hostApp2
    Get-SPEnterpriseSearchServiceInstance -Identity $hostWF1
    Get-SPEnterpriseSearchServiceInstance -Identity $hostWF2
    Get-SPEnterpriseSearchServiceInstance -Identity $hostWF3

     

    Setting up the topology

    $ssa = Get-SPEnterpriseSearchServiceApplication

    $newTopology = New-SPEnterpriseSearchTopology -SearchApplication $ssa

    #SPAPP-SRV1

    New-SPEnterpriseSearchAdminComponent -SearchTopology $newTopology

    -SearchServiceInstance $hostApp1

     

    New-SPEnterpriseSearchCrawlComponent -SearchTopology $newTopology

    -SearchServiceInstance $hostApp1

     

    New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $newTopology

    -SearchServiceInstance $hostApp1

     

    New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $newTopology

    -SearchServiceInstance $hostApp1

     

    New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology

    -SearchServiceInstance $hostApp1 -IndexPartition 0

     

    #SPAPP-SRV2

    New-SPEnterpriseSearchAdminComponent -SearchTopology $newTopology

    -SearchServiceInstance $hostApp2

     

    New-SPEnterpriseSearchCrawlComponent -SearchTopology $newTopology

    -SearchServiceInstance $hostApp2

     

    New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $newTopology

    -SearchServiceInstance $hostApp2

     

    New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $newTopology

    -SearchServiceInstance $hostApp2

     

    New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology

    -SearchServiceInstance $hostApp2 -IndexPartition 0

     

    #SPWF-SRV1 , SPWF-SRV2 , SPWF-SRV3

    New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newTopology

    -SearchServiceInstance $hostWF1

     

    New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newTopology

    -SearchServiceInstance $hostWF2

     

    New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newTopology

    -SearchServiceInstance $hostWF3

    #Activate the Topology

    Set-SPEnterpriseSearchTopology -Identity $newTopology

    # Verify the Topology 

    Get-SPEnterpriseSearchTopology -SearchApplication $ssa

  • Getting Error: This Setup Requires Internet Information Server 5.1 or higher and Windows XP and higher when installing setup project on windows server 2008 and IIS 7

     

    Introduction:

    I was getting the error:

    This Setup Requires Internet Information Server 5.1 or higher and Windows XP and higher when I was trying to install a setup project on windows server 2008 with IIS 7.0.

    After 1 hour of searching, I discovered there was some configuration problems with the Conditions Editor (Requirements on Target Machine)

    Capture0

    Walkthrough:

    • Go to the setup project setup and Launch the Conditions Editor.

    Untitled

    • Right click on the IIS Condition and view the properties

    image

    • Check Condition Formula; it should as the following:

    (IISMAJORVERSION >= "#5" AND IISMINORVERSION >= "#1") OR IISMAJORVERSION >= "#6"

    In the above case, the minimum IIS Version required is 6.

    If you want to install on IIS Version 7.5 and above then use the below condition formula:

    (IISMAJORVERSION >= "#7" AND IISMINORVERSION >= "#5")

  • How to Query Custom View in Event Viewer using C# Code

    Introduction:

    I want to talk about how to filter events from the custom views in windows event viewer; that will give you more ability to drill down and give you more advance filtration options using C# Code.

    Below is an example how to use the same custom view and setting the options in your server side code.

    Walkthrough Scenario:

    Querying the custom view needs to create a dynamic XML Query; a good start to generate the basic XML Query is by generating one using the event viewer:

    image

    image

     

    Now the extra filtration will be using the Event Level and the Time Generated:

    queryString = "<QueryList>" + "<Query Id=\"0\" Path=\"Microsoft-Windows-Application Server-System Services/Admin\">" + "<Select Path=\"Microsoft-Windows-Application Server-System Services/Admin\">*[System[Provider[@Name='Microsoft-Windows-Application Server-System Services' or @Name='Microsoft-Windows-Application Server-System Services Event Collector' or @Name='Microsoft-Windows-Application Server-System Services Hosting' or @Name='Microsoft-Windows-Application Server-System Services IIS Manager' or @Name='Microsoft-Windows-Application Server-System Services Power Shell' and *[System[(" + ddlFilterByType.SelectedItem.Value.ToString() + ") and TimeCreated[timediff(@SystemTime) &lt;= " + ddlFilterByTime.SelectedItem.Value.ToString() + "]]]]]]</Select> " + "<Select Path=\"Microsoft-Windows-Application Server-System Services/Debug\">*[System[Provider[@Name='Microsoft-Windows-Application Server-System Services' or @Name='Microsoft-Windows-Application Server-System Services Event Collector' or @Name='Microsoft-Windows-Application Server-System Services Hosting' or @Name='Microsoft-Windows-Application Server-System Services IIS Manager' or @Name='Microsoft-Windows-Application Server-System Services Power Shell' and *[System[(" + ddlFilterByType.SelectedItem.Value.ToString() + ") and TimeCreated[timediff(@SystemTime) &lt;= " + ddlFilterByTime.SelectedItem.Value.ToString() + "]]]]]]</Select> " + "<Select Path=\"Microsoft-Windows-Application Server-System Services/Operational\">*[System[Provider[@Name='Microsoft-Windows-Application Server-System Services' or @Name='Microsoft-Windows-Application Server-System Services Event Collector' or @Name='Microsoft-Windows-Application Server-System Services Hosting' or @Name='Microsoft-Windows-Application Server-System Services IIS Manager' or @Name='Microsoft-Windows-Application Server-System Services Power Shell' and *[System[(" + ddlFilterByType.SelectedItem.Value.ToString() + ") and TimeCreated[timediff(@SystemTime) &lt;= " + ddlFilterByTime.SelectedItem.Value.ToString() + "]]]]]]</Select> " + "</Query>" + "</QueryList>";

    *[System[(" + ddlFilterByLevel.SelectedItem.Value.ToString() + ") and TimeCreated[timediff(@SystemTime) &lt;= " + ddlFilterByTime.SelectedItem.Value.ToString() + "]]]

    The values for the dropdown list to filter by level will be set as the following:

    <asp:DropDownList ID="ddlFilterByType" runat="server" Height="16px" Width="160px"> <asp:ListItem Text="All Levels" Value="0,1,2,3,4,5" /> <asp:ListItem Text="Critical" Value="Level=1" /> <asp:ListItem Text="Error" Value="Level=2" /> <asp:ListItem Text="Warning" Value="Level=3" /> <asp:ListItem Text="Information" Value="Level=4" /> <asp:ListItem Text="Verbose" Value="Level=5" /> </asp:DropDownList>

    The values for the dropdown list to filter by Time will be set as the following:

    <asp:DropDownList ID="ddlFilterByTime" runat="server" Width="160px"> <asp:ListItem Text="Any Time" Value="0" /> <asp:ListItem Text="Last Hour" Value="3600000" /> <asp:ListItem Text="Last 12 Hours" Value="43200000" /> <asp:ListItem Text="Last 24 Hours" Value="86400000" /> <asp:ListItem Text="Last 7 Days" Value="604800000" /> <asp:ListItem Text="Last 30 Days" Value="2592000000" /> </asp:DropDownList>

    Now we need to initialize an instance of the EventLogReader by specifying and EventLogQuery:

    EventLogQuery eventsQuery = new EventLogQuery("Application", PathType.LogName, queryString); EventLogReader logReader = new EventLogReader(eventsQuery);

    Read the EventLogReader by looping through the EventRecord:

    for (EventRecord Instance = logReader.ReadEvent(); null != Instance; Instance = logReader.ReadEvent()) { String EventID = Instance.Id.ToString(); }
  • Moving SharePoint Databases to Another Server (Without Reconfiguring SharePoint)

    Introduction

    Moving / Migrating Microsoft SharePoint Server Databases from one server to another might be difficult as you need to reconfigure all the related DB(s) to point at the new server. This might be acceptable if we are talking about the SharePoint Content Databases, but how about the below scenarios:

     

    Scenario # 1:

    Moving the SharePoint Configuration DB(s) or the SharePoint Service Application DB(s)?

     

    Scenario # 2:

    Lets consider another scenario, where you want to move the SharePoint DB(s) from a Single Standalone SQL Server to a Highly Available Cluster Server, or maybe even configure it to use on of the new features such as SQL Server AlwaysOn.

    Suggested Solution:

    The answer to the above scenarios might not be as straight forward as it seems, as you might need to reconfigure each DB & Service Separately, so how about suggesting the use of SQL Server Aliases as it could be consider a good starting point for both of the above scenario.

     

    Walkthrough Scenario

    To start take a backup of the SharePoint Server DB(s) that you want to move, this can be easily done using Microsoft SQL Server Management Studio. After the backup is complete restore the Database(s) on the new server.

     

    Note:

    • More information about SQL Server DB Backup & Restore can be found here.
    • This approach will not migrate SQL Server other components such as SSRS or SSAS ... etc. however it could be considered a good start to the migration process.
    • After Defining the SQL Sever Alias the Database on the Source Server will not be accessible and can be removed.

    After successfully restoring the SharePoint DB(s) we need to start configuring the SQL Server Alias. To achieve this goal we need to do the following steps on All the SharePoint Servers in the Farm; such as WFE, APPS ...etc.:

    Go to Start >> Run >> Type CliConfg.exe and the below screen will appear:

    Select the Alias Tab and click Add:


    Select TCP/IP from the Network Libraries and Enter the following Values:


    Server Alias: This is the New SQL Server Name Network Name 

    • In Case of SQL Server FCI then this could be the cluster name
    • In Case of SQL Server AlwaysOn AG this could be the SQL Listener Name

    Server Name: This is the Old SQL Server Network Name

    Port Number (if needed)

     

    And that's its, you will see the new SQL Server Alias added as shown and you are ready to start using the new Database.

     


     

    Don't forget to apply these changes to all the SharePoint Servers in the farm. hope you found it useful

     

    Additional References

    Below are some useful references that provides more information about the items mentioned in the above post:

    Creating a SQL Server alias using the SQL Server Client Network Utility

    Plan Your SharePoint Farm Right with a SQL Server Alias

    Create SQL Server Alias – CliConfg.exe