PowerShell Command to Move a Company to Existing Tenent.
 
            
                
                    postsaurav                
                
                    Member Posts: 708                
            
                        
            
                    Hi all,
Wishing you all a very Happy New Year.
I was working on Mutlitenant and got stuck at one point.
Scenario -
I have 3 companies say A , B & Default.
I want Default in Default Tenant.
I want A & B in a separate tenant say MyTenant.
Here is what i have did till now-
Exported app in a different database.
Mounted App database on the service instance.
created the default Tenant (at this point all 3 companies are in default tenant).
Moved Company A to new Tenant (MyTenant) using below Powershell script -
Worked like charm and Company A moved to MyTenant.
But now when i am trying to Move Company B from Default to Mytenant it end up with error.
Error -
Mount-NAVTenant : Tenant 'MYTenant' already exists.
At \Multitenancy\HowTo-MoveCompanyToTenant.ps1:126 char:5
\Multitenancy\HowTo-MoveCompanyToTenant.ps1:126 char:5
+ Mount-NAVTenant -Id $NewTenantName -ServerInstance $ServerInstance -Database ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (0:Int32) [Mount-NAVTenant], FaultException`1
+ FullyQualifiedErrorId : MicrosoftDynamicsNavServer$MultiTenent,Microsoft.Dynamics.Nav.Management.Cmdlets.MountNavTenant
I thought it is because MyTenant is Already Mounted, so i dismounted it from Service Instance and ran the command again.
It moved the comany to MyTenant but didnt removed it from default tenant.
ERROR -
Remove-NAVCompany : The Company does not exist. Identification fields and values: Name='B'
At \Multitenancy\HowTo-MoveCompanyToTenant.ps1:151 char:11
\Multitenancy\HowTo-MoveCompanyToTenant.ps1:151 char:11
+ Remove-NAVCompany -ServerInstance $ServerInstance -Tenant $OldTenantNa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (0:Int32) [Remove-NAVCompany], FaultException`1
+ FullyQualifiedErrorId : MicrosoftDynamicsNavServer$MultiTenent/default,Microsoft.Dynamics.Nav.Management.Cmdlets.RemoveNavCompany
When i checked in SQL the Company B Exists in Both Tenants Default & MyTenant.
So how can i move multiple companies to a tenant and remove it from default tenant.
Thanks in advance
                Wishing you all a very Happy New Year.
I was working on Mutlitenant and got stuck at one point.
Scenario -
I have 3 companies say A , B & Default.
I want Default in Default Tenant.
I want A & B in a separate tenant say MyTenant.
Here is what i have did till now-
Exported app in a different database.
Mounted App database on the service instance.
created the default Tenant (at this point all 3 companies are in default tenant).
Moved Company A to new Tenant (MyTenant) using below Powershell script -
HowTo-MoveCompanyToTenant -ServerInstance ‘DynamicsNAV71’ -DatabaseServer 'localhost\NAVDEMO' -FromDatabase 'ABC' -CompanyName 'A' -OldTenantName 'default' -NewTenantName 'MYTenant' -ServiceAccount 'NT AUTHORITY\NETWORK SERVICE' -RemoveCompanyWhenMoved
Worked like charm and Company A moved to MyTenant.
But now when i am trying to Move Company B from Default to Mytenant it end up with error.
HowTo-MoveCompanyToTenant -ServerInstance ‘DynamicsNAV71’ -DatabaseServer 'localhost\NAVDEMO' -FromDatabase 'ABC' -CompanyName 'B' -OldTenantName 'default' -NewTenantName 'MYTenant' -ServiceAccount 'NT AUTHORITY\NETWORK SERVICE' -RemoveCompanyWhenMoved
Error -
Mount-NAVTenant : Tenant 'MYTenant' already exists.
At
 \Multitenancy\HowTo-MoveCompanyToTenant.ps1:126 char:5
\Multitenancy\HowTo-MoveCompanyToTenant.ps1:126 char:5+ Mount-NAVTenant -Id $NewTenantName -ServerInstance $ServerInstance -Database ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (0:Int32) [Mount-NAVTenant], FaultException`1
+ FullyQualifiedErrorId : MicrosoftDynamicsNavServer$MultiTenent,Microsoft.Dynamics.Nav.Management.Cmdlets.MountNavTenant
I thought it is because MyTenant is Already Mounted, so i dismounted it from Service Instance and ran the command again.
It moved the comany to MyTenant but didnt removed it from default tenant.
ERROR -
Remove-NAVCompany : The Company does not exist. Identification fields and values: Name='B'
At
 \Multitenancy\HowTo-MoveCompanyToTenant.ps1:151 char:11
\Multitenancy\HowTo-MoveCompanyToTenant.ps1:151 char:11+ Remove-NAVCompany -ServerInstance $ServerInstance -Tenant $OldTenantNa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (0:Int32) [Remove-NAVCompany], FaultException`1
+ FullyQualifiedErrorId : MicrosoftDynamicsNavServer$MultiTenent/default,Microsoft.Dynamics.Nav.Management.Cmdlets.RemoveNavCompany
When i checked in SQL the Company B Exists in Both Tenants Default & MyTenant.
So how can i move multiple companies to a tenant and remove it from default tenant.
Thanks in advance
Thanks & Regards,
Saurav Dhyani
Do you Know this About NAV?
Connect - Twitter | Facebook | Google + | YouTube
Follow - Blog | Facebook Page | Google + Page
0                
            Answers
- 
            I hope you have seen this Great How do I video?
 http://www.youtube.com/watch?v=N3Lj9FJDz3w&list=PL5B63EF419A3B59C8&index=350
- 
            Hi Mohan,
 sorry for delay and thanks for the link.
 Thanks & Regards,
 Saurav Dhyani
 Do you Know this About NAV?
 Connect - Twitter | Facebook | Google + | YouTube
 Follow - Blog | Facebook Page | Google + Page0
- 
            Use
 Dismount-NAVTenant -Tenant 'MYTenant'
 after moving the first company.________________________________
 Gunnar Gestsson
 Microsoft Certified IT Professional
 Dynamics NAV MVP
 http://www.dynamics.is
 http://Objects4NAV.com0
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
- 323 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

