VMM: IP-Address Pools: Unterschied zwischen den Versionen

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche
 
(8 dazwischenliegende Versionen des gleichen Benutzers werden nicht angezeigt)
Zeile 4: Zeile 4:
  
  
== Allocate new IP-Address to a VMM-IPAddress-Pool (Show which is the next IP address that VMM allocate to a VM -> VMM selects the IP-Address) ==
+
== Allocate new IP-Address to a VMM-IPAddress-Pool (Show which is the next IP address that VMM allocate to a VM -> VMM chooses the IP-Address) ==
 
<source lang="powershell">
 
<source lang="powershell">
 
$VM = Get-SCVirtualMachine -Name <"VMName">
 
$VM = Get-SCVirtualMachine -Name <"VMName">
 
$vNICs = $VM.VirtualNetworkAdapters
 
$vNICs = $VM.VirtualNetworkAdapters
 
$IPPool = Get-SCStaticIPAddressPool -Name <"IP-PoolName">
 
$IPPool = Get-SCStaticIPAddressPool -Name <"IP-PoolName">
Grant-SCIPAddress -StaticIPAddressPool $IPPool -GrantToObjectType VirtualMachine -GrantToObjectID $vNICs[0].ID -Description $VM.Name
+
Grant-SCIPAddress -StaticIPAddressPool $IPPool -GrantToObjectType VirtualNetworkAdapter -GrantToObjectID $vNICs[0].ID -Description $VM.Name
 
</source>
 
</source>
  
== Allocate new defined IP-Address to a VMM-IPAddress-Pool ==
+
== Allocate new defined IP-Address to a VMM-IPAddress-Pool (manual) ==
 
<source lang="powershell">
 
<source lang="powershell">
 
$VM = Get-SCVirtualMachine -Name <"VMName">
 
$VM = Get-SCVirtualMachine -Name <"VMName">
 
$vNICs = $VM.VirtualNetworkAdapters
 
$vNICs = $VM.VirtualNetworkAdapters
 
$IPPool = Get-SCStaticIPAddressPool -Name <"IP-PoolName">
 
$IPPool = Get-SCStaticIPAddressPool -Name <"IP-PoolName">
Grant-SCIPAddress -StaticIPAddressPool $IPPool -GrantToObjectType VirtualMachine -GrantToObjectID $vNICs[0].ID -Description $VM.Name -IPAddress <IP-Address>
+
Grant-SCIPAddress -StaticIPAddressPool $IPPool -GrantToObjectType VirtualNetworkAdapter -GrantToObjectID $vNICs[0].ID -Description $VM.Name -IPAddress <IP-Address>
 
</source>
 
</source>
  
Zeile 23: Zeile 23:
 
== Revoke IP-Address ==
 
== Revoke IP-Address ==
 
<source lang="powershell">Get-SCIPAddress -IPAddress <IP-Address> | Revoke-SCIPAddress</source>
 
<source lang="powershell">Get-SCIPAddress -IPAddress <IP-Address> | Revoke-SCIPAddress</source>
 +
 +
 +
 +
== Change VLAN or Static/Dynamic IP of a VM (interactive) ==
 +
<source lang="powershell">
 +
<#
 +
.SYNOPSIS
 +
Switch From Dynamic IP To Static IP Pool.
 +
 +
.DESCRIPTION
 +
Switch From Dynamic IP To Static IP Pool in Virtual Machine Manager.
 +
 +
.NOTES
 +
File Name : Set-SCVMIPAddressMode.ps1
 +
Author    : Charbel Nemnom / Robin Hermann
 +
Date      : 06.12.2019
 +
Version  : 1.1
 +
Requires  : PowerShell Version 3.0 or above, VMM IP Pools defined
 +
OS        : Windows Server 2012R2/2016 with System Center Virtual Machine Manager 2012R2/2016
 +
 +
.LINK
 +
To provide feedback or for further assistance please visit:
 +
https://charbelnemnom.com
 +
https://charbelnemnom.com/2016/03/how-to-switch-a-vm-from-dynamic-ip-to-static-ip-pool-in-virtual-machine-manager-vmm-scvmm-sysctr-hyperv/
 +
 +
.EXAMPLE
 +
./Set-SCVMIPAddressMode -VMMServer <VMMServerName> -VM <VMName>
 +
This example will switch <VMName> from Dynamic IP to Static IP Pool and assign a static IP Address
 +
#>
 +
 +
[CmdletBinding()]
 +
param(
 +
    [Parameter(Mandatory=$true, HelpMessage='VMM Server Name')]
 +
    [Alias('VMMServer')]
 +
    [String]$VMMServerName,
 +
 +
    [Parameter(Mandatory=$true, HelpMessage='Virtual Machine Name')]
 +
    [Alias('VM')]
 +
    [String]$VMName 
 +
 
 +
  )
 +
 +
$VM = Get-SCVirtualMachine -Name $VMName
 +
 +
# Select The VM Network 
 +
$VMNetwork = Get-SCVMNetwork -VMMServer $VMMServerName | Out-Gridview -PassThru -Title 'Select VM Network'
 +
 +
# Select the VM Subnet
 +
$VMSubnet = Get-SCVMSubnet -VMMServer $VMMServerName -VMNetwork $VMNetwork | Out-GridView -PassThru -Title 'Select VM Subnet'
 +
 +
# Select the IP Address Pool
 +
$IPPool = Get-SCStaticIPAddressPool -VMMServer $VMMServerName -VMSubnet $VMSubnet | Out-GridView -PassThru -Title 'Select IP Address Pool'
 +
 +
# Select which Virtual NIC you want to apply Static IP Mode
 +
$NIC = Get-SCVirtualNetworkAdapter -VMMServer $VMMServerName -VM $VM.Name | Out-Gridview -PassThru -Title 'Select VMs vNIC'
 +
 +
# Get free IP address from the IP Pool
 +
$IPAddress = Grant-SCIPAddress -GrantToObjectType VirtualNetworkAdapter -GrantToObjectID $VM.VirtualNetworkAdapters[($NIC.SlotID)].ID -StaticIPAddressPool $IPPool -Description $VM.Name
 +
 +
# Allocate to the vNIC an IP Address from the IP Pool
 +
Set-SCVirtualNetworkAdapter -VMMServer $VMMServerName -VirtualNetworkAdapter $VM.VirtualNetworkAdapters[($NIC.SlotID)] -VMNetwork $VMNetwork -IPv4AddressType Static -IPv4Addresses $IPAddress.Address
 +
 +
# Refresh VM
 +
Read-SCVirtualMachine $VMName
 +
 +
</source>
  
  

Aktuelle Version vom 15. Juli 2020, 07:13 Uhr

Show IP-Address allocated to a IP-Address-Pool

(Get-SCStaticIPAddressPool <"IP-PoolName">) | Get-SCIPAddress | select Name, Description, State, ObjectType


Allocate new IP-Address to a VMM-IPAddress-Pool (Show which is the next IP address that VMM allocate to a VM -> VMM chooses the IP-Address)

$VM = Get-SCVirtualMachine -Name <"VMName">
$vNICs = $VM.VirtualNetworkAdapters
$IPPool = Get-SCStaticIPAddressPool -Name <"IP-PoolName">
Grant-SCIPAddress -StaticIPAddressPool $IPPool -GrantToObjectType VirtualNetworkAdapter -GrantToObjectID $vNICs[0].ID -Description $VM.Name

Allocate new defined IP-Address to a VMM-IPAddress-Pool (manual)

$VM = Get-SCVirtualMachine -Name <"VMName">
$vNICs = $VM.VirtualNetworkAdapters
$IPPool = Get-SCStaticIPAddressPool -Name <"IP-PoolName">
Grant-SCIPAddress -StaticIPAddressPool $IPPool -GrantToObjectType VirtualNetworkAdapter -GrantToObjectID $vNICs[0].ID -Description $VM.Name -IPAddress <IP-Address>


Revoke IP-Address

Get-SCIPAddress -IPAddress <IP-Address> | Revoke-SCIPAddress


Change VLAN or Static/Dynamic IP of a VM (interactive)

<#
 .SYNOPSIS
Switch From Dynamic IP To Static IP Pool.
 
.DESCRIPTION
Switch From Dynamic IP To Static IP Pool in Virtual Machine Manager.
 
.NOTES
File Name : Set-SCVMIPAddressMode.ps1
Author    : Charbel Nemnom / Robin Hermann
Date      : 06.12.2019
Version   : 1.1
Requires  : PowerShell Version 3.0 or above, VMM IP Pools defined
OS        : Windows Server 2012R2/2016 with System Center Virtual Machine Manager 2012R2/2016 
 
.LINK
To provide feedback or for further assistance please visit:
https://charbelnemnom.com
https://charbelnemnom.com/2016/03/how-to-switch-a-vm-from-dynamic-ip-to-static-ip-pool-in-virtual-machine-manager-vmm-scvmm-sysctr-hyperv/
 
.EXAMPLE
./Set-SCVMIPAddressMode -VMMServer <VMMServerName> -VM <VMName>
This example will switch <VMName> from Dynamic IP to Static IP Pool and assign a static IP Address 
#>
 
[CmdletBinding()]
param(
    [Parameter(Mandatory=$true, HelpMessage='VMM Server Name')]
    [Alias('VMMServer')]
    [String]$VMMServerName,
 
    [Parameter(Mandatory=$true, HelpMessage='Virtual Machine Name')]
    [Alias('VM')]
    [String]$VMName   
 
  )
 
$VM = Get-SCVirtualMachine -Name $VMName
 
# Select The VM Network  
$VMNetwork = Get-SCVMNetwork -VMMServer $VMMServerName | Out-Gridview -PassThru -Title 'Select VM Network'
 
# Select the VM Subnet
$VMSubnet = Get-SCVMSubnet -VMMServer $VMMServerName -VMNetwork $VMNetwork | Out-GridView -PassThru -Title 'Select VM Subnet'
 
# Select the IP Address Pool
$IPPool = Get-SCStaticIPAddressPool -VMMServer $VMMServerName -VMSubnet $VMSubnet | Out-GridView -PassThru -Title 'Select IP Address Pool'
 
# Select which Virtual NIC you want to apply Static IP Mode
$NIC = Get-SCVirtualNetworkAdapter -VMMServer $VMMServerName -VM $VM.Name | Out-Gridview -PassThru -Title 'Select VMs vNIC'
 
# Get free IP address from the IP Pool
$IPAddress = Grant-SCIPAddress -GrantToObjectType VirtualNetworkAdapter -GrantToObjectID $VM.VirtualNetworkAdapters[($NIC.SlotID)].ID -StaticIPAddressPool $IPPool -Description $VM.Name
 
# Allocate to the vNIC an IP Address from the IP Pool
Set-SCVirtualNetworkAdapter -VMMServer $VMMServerName -VirtualNetworkAdapter $VM.VirtualNetworkAdapters[($NIC.SlotID)] -VMNetwork $VMNetwork -IPv4AddressType Static -IPv4Addresses $IPAddress.Address
 
# Refresh VM
Read-SCVirtualMachine $VMName