Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xIPAddress: Set-TargetResource fails when given multiple addresses and one or more of those addresses is already present. #323

Closed
jthompci opened this issue Apr 6, 2018 · 0 comments · Fixed by #331
Labels
bug The issue is a bug.

Comments

@jthompci
Copy link

jthompci commented Apr 6, 2018

I have come across unexpected behavior with the xIPAddress resource. It fails when adding multiple addresses if any of the addresses are already present and in the correct state.

Given the scenario:

Prompt#> Get-NetIpAddress -InterfaceAlias Ethernet

  IPAddress         : 192.168.0.1
  InterfaceIndex    : 12
  InterfaceAlias    : Ethernet
  AddressFamily     : IPv4
  Type              : Unicast
  PrefixLength      : 24
  PrefixOrigin      : Manual
  SuffixOrigin      : Manual
  AddressState      : Preferred
  ValidLifetime     : Infinite ([TimeSpan]::MaxValue)
  PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
  SkipAsSource      : False
  PolicyStore       : ActiveStore

And the configuration:

Configuration Example {
  Import-DscResource -ModuleName xNetworking -ModuleVersion 5.6.0.0 -Name xIpAddress
 
  xIPAddress Test {
    IPAddress = @("192.168.0.1/24","192.168.0.2/24")
    AddressFamily = "IPV4"
    InterfaceAlias = "Ethernet"
  }
}

It will fail with the error:

PowerShell DSC resource MSFT_xIPAddress  failed to execute Set-TargetResource functionality with error message: The running command stopped because the preference 
variable "ErrorActionPreference" or common parameter is set to Stop: Instance MSFT_NetIPAddress already exists

It appears that it tries to add the addresses that are already present. You get the same error when running this command under the same circumstances:

New-NetIPAddress -InterfaceAlias Ethernet -IPAddress 192.168.0.1 -AddressFamily IPv4 -PrefixLength 24 -ErrorAction Stop

I did this repro on a Windows 10 PC:

Name                           Value
----                           -----
PSVersion                      5.1.15063.966
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.966
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

I also have experienced the issue on a Windows Server 2016 machine:

Name                           Value
----                           -----
PSVersion                      5.1.14393.2125
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.2125
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
@PlagueHO PlagueHO added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. labels Apr 11, 2018
limiteddenial pushed a commit to limiteddenial/NetworkingDsc that referenced this issue May 11, 2018
limiteddenial pushed a commit to limiteddenial/NetworkingDsc that referenced this issue May 11, 2018
PlagueHO added a commit that referenced this issue May 25, 2018
@joeyaiello joeyaiello removed the help wanted The issue is up for grabs for anyone in the community. label May 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants