Multitenancy PowerShell Script not working

airam
Member Posts: 91
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
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
1
Answers
-
Having the same issue, did you find the solution to that problem? Thanks in advance!0
-
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.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions