Search code examples
powershellwindows-server-2012-r2terminal-servicesterminal-services-gateway

How to set IPAddress as "All Unassigned" using command line?


I read this SetIPAndPort and tried to set the transport of RD Gateway by using powershell, but it didn't work, here is my command line:

$HTTPPort = 7443
Get-CimInstance -Namespace root/CIMV2/TerminalServices -ClassName Win32_TSGatewayServerSettings | Invoke-CimMethod -MethodName SetIPAndPort -Arguments @{TransportType = 1; Port = $HTTPPort; OverrideExisting = 1}

It returned value 2147749896, according to the Docs, it means one of the parameters to the call is not correct, so I tried to give full parameters, which including IPAddress, but whatever I tried, I just can't assign it as "All Unassigned", I must assigned an IP to pass, that's a big problem to me.

@{TransportType = 1; IPAddress = $IPAddress; Port = $HTTPPort; OverrideExisting = 1}

"0.0.0.0", "All Unassigned", "All", "Null", "None", "0", all of them can't reach my goal and returned error value 2147749896 or 2147952422.

How can I set IPAddress as All Unassigned by using SetIPAndPort command line?

OS:
Windows 2012 R2


Solution

  • I solved, use asterisk * to set IPAddress as All Unassigned, like this:

    @{ TransportType = 1;
       IPAddress = "*";
       Port = 7443;
       OverrideExisting = 1
    }