Share via


Create Logical Network and network site in SCVMM 2012 using powershell

Hey folks

You must be creating logical networks and network sites in SCVMM from UI But  I thought it will be a good idea to powershell it . This will help when creating and destroying test environments

Import-Module virtualmachinemanager 
  
$name = Read-Host " Enter the Logical network name "
$sitename = Read-Host " Enter the site name"
  
  
$management= Read-Host " Enter the management network  full subnet e.g 10.10.10.0/24"
$managementVLAN = Read-host "Enter the management VLAN ID"
$livemigration = Read-Host " Enter the live migration  full subnet e.g 10.10.10.0/24"
$livemigrationVLAN = Read-host "Enter the live migration VLAN ID"
$clusternetwork = Read-Host " Enter the Cluster heartbeat network  full subnet e.g 10.10.10.0/24"
$clusternetworkVLAN = Read-host "Enter the Clusternetwork VLAN ID"
  
$allHostGroups = @() 
$allHostGroups += Get-SCVMHostGroup -Name "All Hosts"
$allSubnetVlan = @() 
$allSubnetVlan += New-SCSubnetVLan -Subnet $management -VLanID $managementVLAN 
$allSubnetVlan += New-SCSubnetVLan -Subnet $livemigration -VLanID $livemigrationVLAN 
$allSubnetVlan += New-SCSubnetVLan -Subnet $clusternetwork -VLanID $clusternetworkVLAN 
  
$allSubnetVlan 
$logicalNetwork = New-SCLogicalNetwork -Name $name -LogicalNetworkDefinitionIsolation $true -EnableNetworkVirtualization $false -UseGRE $false -IsPVLAN $false
New-SCLogicalNetworkDefinition -Name $sitename -LogicalNetwork $logicalNetwork -VMHostGroup $allHostGroups -SubnetVLan $allSubnetVlan -RunAsynchronously