* Adapted the powershell to connect to the central with a dedicated sql login * reverted script 9_Update_FTPLogin_Central to the original version * script 9_Update_FTPLogin_Central is executed on the central directly with a dedicated login * reverted scripts 20_update_system_site_centrale.sql and 21_update_point_of_sale_centrale.sql to work locally only * scripts scripts 20_update_system_site_centrale.sql and 21_update_point_of_sale_centrale.sql are executed on the cenrtal with a specific login and on the local instance * when fetching the mac addresses, only take up interfaces in account and group the results by mac addresses, to avoid virtual mac addresses duplicate causing an error
45 lines
2.1 KiB
Transact-SQL
45 lines
2.1 KiB
Transact-SQL
/*=============================================================================
|
|
TPDT-283
|
|
|
|
Update central system_site values for a specific OU
|
|
|
|
Parameters
|
|
----------------------
|
|
In script parameters updated from Powershell are present:
|
|
@ou_id The id of the OU we need to update. This id is fetched from the local machine being migrated.
|
|
@fqdn The FQDN of the machine being migrated to Azure. This is fetched from a DNS request, not built.
|
|
@alias The alias of the machine being migrated to Azure. This is logically built from the FQDN
|
|
|
|
Context
|
|
----------------------
|
|
This script is called from a powershell in the task sequence during the migration to Azure.
|
|
The excution context is the local pharmacy being moved to Azure, but updating the central via the linked server arizonaCash.
|
|
It ensure that the system_site reflect the new hostname of the machine, so that labels are delivered correctly.
|
|
|
|
Creation : 04.03.2024 / TSC
|
|
Modifications:
|
|
07.03.2024 TSC Rewrote to connect to the central through the pharmacy linked server ArizonaCash
|
|
The values in the local pharmacy are updated as well
|
|
15.03.2024 TSC Went back to a local update. this script will be run both locally and on the central from the powershell executing it
|
|
=============================================================================*/
|
|
USE [master];
|
|
|
|
DECLARE @ou_id INT = $ou_id;
|
|
DECLARE @fqdn VARCHAR(100) = '$fqdn';
|
|
DECLARE @alias VARCHAR(100) = '$alias';
|
|
|
|
UPDATE ss
|
|
SET [ss].[SS_server_name] = @alias
|
|
, [ss].[SS_IP_server_address] = @alias
|
|
, [ss].[SS_domain_name] = @fqdn
|
|
FROM [arizona].[dbo].[Organizational_unit] ou
|
|
JOIN [arizona].[dbo].[System_site] ss ON ss.[System_site_ID] = ou.[OU_system_site]
|
|
WHERE ou.[Organizational_unit_ID] = @ou_id;
|
|
|
|
UPDATE ssi
|
|
SET [ssi].[SSSI_SQL_instance_name] = @alias+'\APSSQL'
|
|
FROM [arizona].[dbo].[Organizational_unit] ou
|
|
JOIN [arizona].[dbo].[System_site] ss ON ss.[System_site_ID] = ou.[OU_system_site]
|
|
JOIN [arizona].[dbo].[System_site_SQL_instance] ssi ON ssi.[SSSI_system_site] = ss.[System_site_ID]
|
|
WHERE ou.[Organizational_unit_ID] = @ou_id;
|