techblog

Create Management Links via PowerShell

Mar 5, 2013 by Christoph // Leave a Comment

If you want to manage some of the Service Applications in SharePoint, like User Profile Service Application or the Search Service Application, you have to go into Central Administration, click Manage Service Applications, select the Service Application and click Manage. When you are there and start playing around with settings, you will sometimes end up in a weird dead-end where you are  not able to get back to the main Management Page of the Service Application. The only way back is to go to the Central Admin main page and click your way through it again (or hit “back back back back …” in your browser).

This is deeply annoying and I am not sure why they haven’t been able to fix this behaviour yet.

My solution to this problem is to add Links to the standard link webpart on the Central Administration start page, that will lead me to the Service Application Management Pages. So if I get lost somewhere during configuration, I simply can click  “Central Administration” and the desired Service Application Management link afterwards to bring me back into the game.

Since I love doing configuration via PowerShell and I was just working on an installation script for SharePoint 2013 anyway, I created a function to add the most important links to the Service Application Management Pages during the installation and configuration process.

The outcome

After running the script, you will find the desired Management links on the front page of the Central Administration.

image

 

PowerShell Script

The script is getting the Library from the Central Administration, searching for links that are already added and will update the links or creates new links if necessary. The links are combinations of a Management Page Url and the ID of the Service Application.

function Create-CentralAdministrationLinks
{
    Write-Host "Adding links to Central Administration"

    $caUrl = "http://spserver01:11111"
    $searchSAItem = $null
    $userProfileItem = $null

    Try
    {
        $resourceList = (Get-SPWeb $caUrl).Lists["Resources"]
    }
    Catch
    {
        Write-Host "Error, list cannot be retrieved"
    }

    if($resourceList -ne $null)
    {
        #Get Items if already exist
        foreach($item in $resourceList.Items)
        {
             if($item["URL"].Contains("searchadministration.aspx?appid="))
             {
                    $searchSAItem = $item
             }
             if($item["URL"].Contains("_layouts/15/ManageUserProfileServiceApplication.aspx?ApplicationID="))
             {
                    $userProfileItem = $item
             }
        }

        #Create User Profile Administration Link
        Write-Message " create links for User Profile Service"
        $userProfileTypeName = "User Profile Service Application"
        $userProfileSA = Get-SPServiceApplication | where { $_.TypeName -eq $userProfileTypeName }
        $userProfileLink = $caUrl + "_layouts/15/ManageUserProfileServiceApplication.aspx?ApplicationID=" + $userProfileSA.Id

        if($userProfileItem -eq $null)
        {
             $userProfileItem = $resourceList.Items.Add()
        }
        $userProfileItem["URL"] = "$userProfileLink, Manage User Profile Service"

        Try
        {
            $userProfileItem.Update()
            Write-Host "OK, link created"
        }
        Catch
        {
            Write-Message "Error. Could not create link for User Profile Service."
        }

        #Create Search Administration Link
        Write-Message " create links for Search Service"
        $searchSATypeName = "Search Service Application"
        $searchSA = Get-SPServiceApplication | where { $_.TypeName -eq $searchSATypeName }
        $searchSALink = $caUrl + "searchadministration.aspx?appid=" + $searchSA.Id

        if($searchSAItem -eq $null)
        {
             $searchSAItem = $resourceList.Items.Add()
        }
        $searchSAItem["URL"] = "$searchSALink, Manage Search Service"

        Try
        {
            $searchSAItem.Update()
            Write-Host "OK, link created"
        }
        Catch
        {
            Write-Message "Error. Could not create link for Search Service."
        }
    }
}

I am only adding two links for clarification, but you can do so with a lot more Service Application Management pages like Secure Store and so on.

Have fun!


Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Copyright © 2012 techblog All Rights Reserved.

The posts on this weblog are provided “AS IS” with no warranties, and confer no rights. The opinions expressed herein are personal and do not represent those of my employer.

Designed & Developed by ThemeElephant