99 `MSReportServer_ConfigurationSetting` CIM instance.
1010
1111 This command returns information about IP addresses that can be
12- used for URL reservations and SSL bindings.
12+ used for URL reservations and SSL bindings. Each returned object
13+ includes the IP address, IP version (V4 or V6), and whether DHCP
14+ is enabled. If DHCP is enabled, the IP address is dynamic and should
15+ not be used for TLS bindings.
1316
1417 The configuration CIM instance can be obtained using the
1518 `Get-SqlDscRSConfiguration` command and passed via the pipeline.
2023 `Get-SqlDscRSConfiguration` command. This parameter accepts pipeline
2124 input.
2225
23- . PARAMETER Lcid
24- Specifies the language code identifier (LCID) for the request.
25- If not specified, defaults to the operating system language. Common
26- values include 1033 for English (US).
27-
2826 . EXAMPLE
2927 Get-SqlDscRSConfiguration -InstanceName 'SSRS' | Get-SqlDscRSIPAddress
3028
3129 Gets all available IP addresses for the Reporting Services instance.
3230
3331 . EXAMPLE
3432 $config = Get-SqlDscRSConfiguration -InstanceName 'SSRS'
35- Get-SqlDscRSIPAddress -Configuration $config -Lcid 1033
33+ Get-SqlDscRSIPAddress -Configuration $config | Where-Object -FilterScript { $_.IPVersion -eq 'V4' }
3634
37- Gets available IP addresses with a specific LCID .
35+ Gets available IPv4 addresses for the Reporting Services instance .
3836
3937 . INPUTS
4038 `Microsoft.Management.Infrastructure.CimInstance`
4139
4240 Accepts MSReportServer_ConfigurationSetting CIM instance via pipeline.
4341
4442 . OUTPUTS
45- `System.String `
43+ `[ReportServerIPAddress[]] `
4644
47- Returns the IP addresses available on the machine.
45+ Returns an array of ReportServerIPAddress objects containing the IP
46+ address, IP version, and DHCP status.
4847
4948 . NOTES
5049 This command calls the WMI method `ListIPAddresses`.
@@ -56,57 +55,52 @@ function Get-SqlDscRSIPAddress
5655{
5756 [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute (' UseSyntacticallyCorrectExamples' , ' ' , Justification = ' Because the examples use pipeline input the rule cannot validate.' )]
5857 [CmdletBinding ()]
59- [OutputType ([System.String ])]
58+ [OutputType ([ReportServerIPAddress [] ])]
6059 param
6160 (
6261 [Parameter (Mandatory = $true , ValueFromPipeline = $true )]
6362 [System.Object ]
64- $Configuration ,
65-
66- [Parameter ()]
67- [System.Int32 ]
68- $Lcid
63+ $Configuration
6964 )
7065
7166 process
7267 {
7368 $instanceName = $Configuration.InstanceName
7469
75- if (-not $PSBoundParameters.ContainsKey (' Lcid' ))
76- {
77- $Lcid = (Get-OperatingSystem ).OSLanguage
78- }
79-
8070 Write-Verbose - Message ($script :localizedData.Get_SqlDscRSIPAddress_Getting -f $instanceName )
8171
8272 $invokeRsCimMethodParameters = @ {
8373 CimInstance = $Configuration
8474 MethodName = ' ListIPAddresses'
85- Arguments = @ {
86- Lcid = $Lcid
87- }
8875 }
8976
9077 try
9178 {
92- $result = Invoke-RsCimMethod @invokeRsCimMethodParameters - ErrorAction ' Stop '
79+ $result = Invoke-RsCimMethod @invokeRsCimMethodParameters
9380
94- # Return the IP addresses
95- if ($result.IPAddress )
81+ # Return the IP addresses as ReportServerIPAddress objects
82+ if ($result.IPAddress -and $result .IPAddress.Count -gt 0 )
9683 {
97- return $result.IPAddress
84+ $ipAddressObjects = for ($i = 0 ; $i -lt $result.IPAddress.Count ; $i ++ )
85+ {
86+ $ipAddressObject = [ReportServerIPAddress ]::new()
87+ $ipAddressObject.IPAddress = $result.IPAddress [$i ]
88+ $ipAddressObject.IPVersion = $result.IPVersion [$i ]
89+ $ipAddressObject.IsDhcpEnabled = $result.IsDhcpEnabled [$i ]
90+
91+ $ipAddressObject
92+ }
93+
94+ return $ipAddressObjects
9895 }
9996 }
10097 catch
10198 {
102- $PSCmdlet.ThrowTerminatingError (
103- [System.Management.Automation.ErrorRecord ]::new(
104- ($script :localizedData.Get_SqlDscRSIPAddress_FailedToGet -f $instanceName , $_.Exception.Message ),
105- ' GSRSIP0001' ,
106- [System.Management.Automation.ErrorCategory ]::InvalidOperation,
107- $Configuration
108- )
109- )
99+ $errorMessage = $script :localizedData.Get_SqlDscRSIPAddress_FailedToGet -f $instanceName , $_.Exception.Message
100+
101+ $errorRecord = New-ErrorRecord - Exception (New-InvalidOperationException - Message $errorMessage - PassThru) - ErrorId ' GSRSIP0001' - ErrorCategory ' InvalidOperation' - TargetObject $Configuration
102+
103+ $PSCmdlet.ThrowTerminatingError ($errorRecord )
110104 }
111105 }
112106}
0 commit comments