From cd305c307ebc1ac2bed89851b4fdeed0de17254a Mon Sep 17 00:00:00 2001 From: Wanli Mao Date: Wed, 19 Jun 2024 19:22:57 +0800 Subject: [PATCH] add custom script sample --- .../customScript/SetupCustomDns/main.cmd | 1 + .../customScript/SetupCustomDns/setupdnsserver.ps1 | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 SamplesV2/SQLServerIntegrationServices/customScript/SetupCustomDns/main.cmd create mode 100644 SamplesV2/SQLServerIntegrationServices/customScript/SetupCustomDns/setupdnsserver.ps1 diff --git a/SamplesV2/SQLServerIntegrationServices/customScript/SetupCustomDns/main.cmd b/SamplesV2/SQLServerIntegrationServices/customScript/SetupCustomDns/main.cmd new file mode 100644 index 00000000..a1b3af80 --- /dev/null +++ b/SamplesV2/SQLServerIntegrationServices/customScript/SetupCustomDns/main.cmd @@ -0,0 +1 @@ +powershell ./setupdnsserver.ps1 "'168.63.129.16'" \ No newline at end of file diff --git a/SamplesV2/SQLServerIntegrationServices/customScript/SetupCustomDns/setupdnsserver.ps1 b/SamplesV2/SQLServerIntegrationServices/customScript/SetupCustomDns/setupdnsserver.ps1 new file mode 100644 index 00000000..10dff0e5 --- /dev/null +++ b/SamplesV2/SQLServerIntegrationServices/customScript/SetupCustomDns/setupdnsserver.ps1 @@ -0,0 +1,11 @@ +$CustomDNSServers = $args[0] + +$ips = Get-NetIPAddress -AddressFamily IPv4 +for ($i = 0; $i -lt $ips.Count; $i++) +{ + $ip = $ips[$i] + if ($ip.IPAddress -ne "127.0.0.1" -and (-not $ip.IPAddress.StartsWith("169.254"))) + { + Set-DnsClientServerAddress -InterfaceIndex $ip.InterfaceIndex -ServerAddresses $CustomDNSServers.Split(" ") + } +} \ No newline at end of file