NAV 2013 R2: Powershell function to check if ServerInstance is Multitenant or not

Hi, to end the year with – here is a small tip.

I’m working on improving the Backup/Restore procedure from this blogpost .. . While doing that, I was looking for a way to see whether my current instance was actually a Multitenant-server or not. In a way, I had to be able to read this configuration in powershell:


And I found a way .. by looping the output of the Get-NAVServerConfiguration commandlet. Here is the function:

function Get-NAVIsMultiTenantServerInstance
{
    [CmdletBinding()]
    param (
        [parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
        [String]$ServerInstance
    )
    PROCESS
    {   
        $CurrentServerConfig = Get-NAVServerConfiguration -ServerInstance $ServerInstance
        foreach ($CurrentServerConfigKey in $CurrentServerConfig)
        {
            if ($CurrentServerConfigKey.key -eq "Multitenant")
            {
                if ($CurrentServerConfigKey.Value -eq "false")
                {
                    return $false
                }
                else
                {
                    return $true    
                }
            }
        }
    }
} 

Don’t know if you like the function-name – but look at the function.. . May be there are smarter, better, more performant, more stable ways to do it .. if so .. please share :-).

In the mean time, this is how I can use the function (for example in my Backup-function):


Enjoy!

5.00 avg. rating (97% score) - 1 vote

Permanent link to this article: https://www.waldo.be/2013/12/31/nav-2013-r2-powershell-function-to-check-if-serverinstance-is-multitenant-or-not/

3 comments

4 pings

  1. Hi Waldo, here’s a snippet to replace the loop to get the required value:

    (Get-NAVServerConfiguration -ServerInstance $serverInstance -AsXML).SelectSingleNode(‘configuration/appSettings/add[@key=”Multitenant”]’).value

    Enjoy the NY festivities 🙂

      • waldo on January 2, 2014 at 8:04 am
        Author

      That is indeed a nicer way to replace the loop :-).
      Thanks for sharing!

  2. I think this snippet is really works…..thanks for posting

  1. […] Bron : Waldo’s Blog Lees meer… […]

  2. […] might remember this blogpost: NAV 2013 R2: Powershell function to check if ServerInstance is Multitenant or not. It was a small tip on how to check a certain […]

  3. […] might remember this blogpost: NAV 2013 R2: Powershell function to check if ServerInstance is Multitenant or not. It was a small tip on how to check a certain […]

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.