Connect-VIServer virtualcenter function set-ip { param ( [Parameter(Mandatory=$True, HelpMessage="Enter an CSV filename, eg. servers.xml", ParameterSetName = "One")]` [string]$File ) $Global:newcsv = Import-CSV $file $NewCsv |ForEach-Object { $Global:NAME = $_.NAME $Name |Out-File c:\SSvr.txt [string]$Global:ipaddr = $_.ipaddr [string]$Global:subnet = $_.subnet $Global:NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -ComputerName $NAME | where{$_.IPEnabled -eq “TRUE”} #Get-WmiObject -list win32_networkadapterconfiguration -ComputerName $NAME foreach($Global:NIC in $NICs) { $gway = $_.gway $DNSServers = $_.DNS1,$_.DNS2 $NIC.SetWINSServer($_.Wins1,$_.Wins2) Write-Host "WINS Set" $_.Wins1,$_.Wins2 $NIC.SetGateways($gway) Write-Host "GateWay Set" $_.gway $NIC.SetDNSServerSearchOrder($DNSServers) Write-Host "DNS Set" $DNSServers $NIC.SetDynamicDNSRegistration($TRUE,$TRUE) Write-Host "DNS Registration Set" $NIC.SetTcpipNetbios($TRUE) Write-Host "Netbios Over TCPIP" $DNSSuffix = @("cat.com"),@("dog.com"),@("rat.com"),@("mat.com") #this needs to be replaced with vairables #$nic1 = [wmiclass] "win32_networkadapterconfiguration" $Global:NIC1 = Get-WmiObject -list win32_networkadapterconfiguration -ComputerName $_.Name $nic1.SetDNSSuffixSearchOrder($DNSSuffix) #Invoke-WmiMethod -path Win32_NetworkAdapterConfiguration -Name SetDNSSuffixSearchOrder -ArgumentList $DNSSuffix #$nic.SetDNSSuffixSearchOrder(@("dog.com","cat.com","rat.com","pig.com")) #$global:nicST = Gwmi win32_NetworkAdapterConfiguration # Start-Job -Argumentlist ($NIC,$NAME) -ScriptBlock { #Tried this with -inputobject also can't get it to work #param($NIC,$NAME) $computer = Get-WMIObject Win32_NetworkAdapterConfiguration -ComputerName $NAME #$Global:NICw = Get-WMIObject Win32_NetworkAdapterConfiguration -ComputerName $NAME #$NICs.psbase.scope.options.timeout = 5 * 10000000 #$NIC.EnableStatic($ipaddr,$subnet) # Original Line $computer.EnableStatic($NIC.IPAddress,"255.255.255.0") #Write-Host "IP and SubNet Set" #$NIC.Subnet # } # $NIC.SetDNSDomain($_.DNSDom) # $_.DNSDom #$NIC.SetDynamicDNSRegistration($TRUE,$TRUE) $VLAN = $_.VLAN Get-VM $_.Name | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $VLAN $_.VLAN } } } set-ip