vmware-archive / powernsx

PowerShell module that abstracts the VMware NSX-v API to a set of easily used PowerShell functions
173 stars 90 forks source link

Error when adding service to servicegroup #573

Open supersjimmie opened 5 years ago

supersjimmie commented 5 years ago

Code:

$sv = Get-NsxService "DHCP-Client"
Get-NsxServiceGroup -Name "SG_DHCP" | Add-NsxServiceGroupMember -Member $sv

The service is added to the servicegroup, but the code returns an error:

invoke-nsxwebrequest : Invoke-NsxWebRequest : The NSX API response received indicates a failure. 400 : Bad Request : Response Body: <?xml version="1.0" encoding="UTF-8"?>
<error><errorCode>301</errorCode><details>Requested member application-cf8dd5a6-c03e-4e80-9836-17ba97bfaa0b is not a valid member for addition to Security Group 
applicationgroup-6.</details><moduleName>core-services</moduleName></error>
At C:\Program Files\WindowsPowerShell\Modules\PowerNSX\3.0.1125\PowerNSX.psm1:26678 char:21
+ ...     $null = invoke-nsxwebrequest -method "PUT" -uri $URI -connection  ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidResult: (Invoke-NsxWebRequest:String) [Invoke-NsxWebRequest], InternalNsxApiException
    + FullyQualifiedErrorId : NsxAPIFailureResult,Invoke-NsxWebRequest

This does look like I try to add an invalid member type, but its not (and it IS added so that proves that it is not in invalid member type.

When I rename the service to "DHCPClient" without the dash, all works without the error.