Difference between revisions of "Vsphere Powercli"
Jump to navigation
Jump to search
(Created page with "re-register ips with dhcp ``` $Datacenter = "" $vCenter = "" Connect-VIServer $vCenter $vmlist = Get-Cluster "" | Get-VM # | Select @{N="IP Address";E={@($_.guest.IPAddress[0...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 3: | Line 3: | ||
$Datacenter = "" | $Datacenter = "" | ||
$vCenter = "" | $vCenter = "" | ||
− | |||
Connect-VIServer $vCenter | Connect-VIServer $vCenter | ||
$vmlist = Get-Cluster "" | Get-VM | $vmlist = Get-Cluster "" | Get-VM | ||
Line 14: | Line 13: | ||
$script0 = "Register-DNSClient" | $script0 = "Register-DNSClient" | ||
Invoke-VMScript $script0 -vm $vmName -GuestCredential $GetCred | Invoke-VMScript $script0 -vm $vmName -GuestCredential $GetCred | ||
− | #Invoke-Command -ComputerName $vm -Credential $GetCred -ScriptBlock { Register-DnsClient } | + | # Invoke-Command -ComputerName $vm -Credential $GetCred -ScriptBlock { Register-DnsClient } |
− | #sleep 10 | + | # sleep 10 |
} | } | ||
``` | ``` |
Latest revision as of 15:17, 11 June 2021
re-register ips with dhcp
$Datacenter = "" $vCenter = "" Connect-VIServer $vCenter $vmlist = Get-Cluster "" | Get-VM # | Select @{N="IP Address";E={@($_.guest.IPAddress[0])}} $sleep = sleep 10 $GetCred = Get-Credential foreach ($vm in $vmlist) { $vmName = Get-VM $vm $script0 = "Register-DNSClient" Invoke-VMScript $script0 -vm $vmName -GuestCredential $GetCred # Invoke-Command -ComputerName $vm -Credential $GetCred -ScriptBlock { Register-DnsClient } # sleep 10 }