Multitenancy PowerShell Script not working

airamairam Member Posts: 89
hi, we have this scenario:

1. Separate SQL and NAV Servers
2. Multitenancy enabled - trying to move companies from a single tenant to multiple tenants
3. SQL Server 2017 - SQL Server Management Studio 18

I'm working on the NAV Server, where I am importing the NAVMultitenancySamples.psm1 and running the HowTo-MoveCompanyToTenant powershell command

From my understanding is that since I'm running these from the NAV Server, I need to update the HowTo-MoveCompanyToTenant.ps1 to use the RemoteSession command to read the SQLPS module from the SQL server, and I updated:

$ErrorActionPreference = 'Stop'
$shouldContinue = $true
$RemoteSession = New-PSSession -ComputerName sql server name

Import-NAVManagementModule
Import-NAVAppsManagementModule
Invoke-Command -Session $RemoteSession {Import-Module SqlPsModule}
Import-PSSession -Session $RemoteSession -SqlPsModule -DisableNameChecking

but I'm getting this error "The specified module 'SqlPsModule' was not loaded because no valid module file was found in any module directory."


I imported the SqlPsModule on the SQL Server

ModuleType Version Name ExportedCommands

----
Manifest 14.0 SQLPS {Backup-SqlDatabase, Save-SqlMigrationReport, Add-SqlAvail...



Any tips or help is much appreciated!

Thanks in advance

Answers

  • LCostaLCosta Member Posts: 33
    Having the same issue, did you find the solution to that problem? Thanks in advance!
  • LCostaLCosta Member Posts: 33
    I've found the solution. You need to install:
    SQLSysClrTypes.msi
    SharedManagementObjects.msi
    PowerShellTools.MSI
    in this order, you can check more information on this url:
    https://gist.github.com/majkinetor/54076e7a6296138c06c91a1915af3cd6

    then check if you can do "Import-Module -Name SQLPS"

    If it works, close the PowerShell and open again so that you can use the HowTo-MoveCompanyToTenant.
Sign In or Register to comment.