Reply to Message

View discussion in a popup

Replying to:
mk_ultra
Contributor
Contributor

Invalid value in DNS parameter: "System.String[]"

Hello, I am trying to dynamically set a host's DNS server to the local domain controller in the cluster. It sounds like this may just be an object type error? It works when I set the $DNSServer variables to a "[ip address]". What is the difference between a String[] and a System.String[] ?
 
$DomainController = Get-Cluster $ClusterName | Get-VM | Where-Object {$_.Name -like "*999"}
$DomainControllerIP = $DomainController.Guest.IPAddress
$DNSServer1 = $DomainControllerIP
$DNSServer2 = "[redacted]"
 
$VMHostNetwork = Get-VMHostNetwork -Host $IPAddress
Set-VMHostNetwork -Network $VMHostNetwork -DomainName $SearchDomain -SearchDomain $SearchDomain -HostName $HostName -DNSAddress $DNSServer1, $DNSServer2 -DnsFromDhcp:$false
 
Full error:
Set-VMHostNetwork : 5/15/2023 8:29:43 AM Set-VMHostNetwork Invalid value in DNS parameter: "System.String[]"
+ ... Set-VMHostNetwork -Network $VMHostNetwork -DomainName $Se ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-VMHostNetwork], InvalidArgument
+ FullyQualifiedErrorId : Core_SetVmHostNetwork_TryValidateParameterList_InvalidDNSName,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.SetVMHostNetwork
Reply
0 Kudos