Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell Help Request - getting error Add-VMNetworkAdapterExtendedAcl : Cannot convert 'System.String[]' to the type 'System.String' required by parameter 'RemoteIPAddress'. Specified method is not supported.

$
0
0

Hi All

I wonder if anyone can help me in a late night and stressful attempt to get something working :)

so the extended port acls below are what i'm trying to apply and in particular i get this error on the last line of code

error Add-VMNetworkAdapterExtendedAcl : Cannot convert 'System.String[]' to the type 'System.String' required by parameter 'RemoteIPAddress'. Specified method is not supported.

in the $servers.ipaddresses array there is like a dozen ip addresses which i want to apply in turn to each vm? using the bold command below

Any suggestions how i can fix this error please?

------------------------------------------------------------------------------------------------------------------------

#Collating VM Names and IP Addresses (Minus Replicas)
$servers = get-vm "test*" | ?{$_.ReplicationMode -ne “Replica”} | Select -ExpandProperty NetworkAdapters | Select VMName, IPAddresses

#Filtering Blank Entries
$servers = $servers | Where-Object {$_.ipaddresses -ne $null}

# Adding PORT ACLS to Environment Servers
foreach ($server in $servers) {
Write-Host "

#Doing Server " $server.VMName
# Block all IP's outgoing to Environment VMs
Add-VMNetworkAdapterExtendedAcl -vmname $server.vmname -VMNetworkAdapterName domain –Action Deny –Direction Outbound –Weight 1
# Block all IP's incoming to Environment VMs
Add-VMNetworkAdapterExtendedAcl -vmname $server.vmname -VMNetworkAdapterName domain –Action Deny –Direction inbound –Weight 2
# Allow RDP 
Add-VMNetworkAdapterExtendedAcl -vmname $server.vmname -VMNetworkAdapterName domain –Action allow –Direction inbound -localport "3389" -protocol "TCP" –Weight 100 -Stateful $true 

#Allow all local IPs outgoing from Performance Servers
Add-VMNetworkAdapterExtendedAcl -VMName $server.vmname -VMNetworkAdapterName domain -LocalIPAddress any -direction Outbound -Action Allow -weight 101

Add-VMNetworkAdapterExtendedAcl -VMName $server.vmname -VMNetworkAdapterName public -RemoteIPAddress $server.ipaddresses -direction inbound -Action Allow -weight 102
}


Viewing all articles
Browse latest Browse all 21975

Trending Articles