SCVMM – Round 2 – How to create a Private Cloud using PowerShell
Posted
by Waclaw Chrabaszcz
on Geeks with Blogs
See other posts from Geeks with Blogs
or by Waclaw Chrabaszcz
Published on Fri, 28 Jun 2013 01:27:39 GMT
Indexed on
2013/06/28
10:22 UTC
Read the original article
Hit count: 322
SCVMM 2012
|powershell
Originally posted on: http://geekswithblogs.net/Wchrabaszcz/archive/2013/06/28/scvmm--round-2--how-to-create-a-private.aspx
Have you ever seen "A Bridge too far" movie? To not to wake up a click too far, it is good to script some tasks. Yes of course we can follow wizards, but some of us want to be warriorsJ. A small tip, take a look on credentials and system GUID examples. I don't know how about you, but for me it will be really useful in the future.
# credents
$credential = Get-Credential
New-SCRunAsAccount -Name "TESTDOMAIN\Administrator" -Credential $credential
#storage
$opsMgrServerCredential = Get-SCRunAsAccount -Name "TESTDOMAIN\Administrator"
New-SCStorageClassification -Name "Bronze" -Description "" –RunAsynchronously
New-SCStorageClassification -Name "Silver" -Description "" –RunAsynchronously
New-SCStorageClassification -Name "Gold" -Description "" –RunAsynchronously
# add a shared storage
Find-SCComputer -ComputerName "dc.TESTDOMAIN.net"
Add-SCStorageProvider -AddWindowsNativeWmiProvider -Name "dc.TESTDOMAIN.net" -RunAsAccount $opsMgrServerCredential -ComputerName "dc.TESTDOMAIN.net"
$fileServer = Get-SCStorageFileServer "dc.TESTDOMAIN.net"
$fileShares = @()
$fileShares += Get-SCStorageFileShare -Name "VMMLibrary"
Set-SCStorageFileServer -StorageFileServer $fileServer -AddStorageFileShareToManagement $fileShares –RunAsynchronously
#fabric network
$logicalNetwork = New-SCLogicalNetwork -Name "TESTDOMAIN-Service-Network" -LogicalNetworkDefinitionIsolation $false -EnableNetworkVirtualization $true -UseGRE $true -IsPVLAN $false
$allHostGroups = @()
$allHostGroups += Get-SCVMHostGroup -Name "All Hosts"
$allSubnetVlan = @()
$allSubnetVlan += New-SCSubnetVLan -Subnet "10.0.0.0/24" -VLanID 0
New-SCLogicalNetworkDefinition -Name "TESTDOMAIN-Service-Network_0" -LogicalNetwork $logicalNetwork -VMHostGroup $allHostGroups -SubnetVLan $allSubnetVlan
#IP pool
$logicalNetwork = Get-SCLogicalNetwork -Name "TESTDOMAIN-Service-Network"
$logicalNetworkDefinition = Get-SCLogicalNetworkDefinition -LogicalNetwork $logicalNetwork -Name "TESTDOMAIN-Service-Network_0"
# Gateways
$allGateways = @()
$allGateways += New-SCDefaultGateway -IPAddress "10.0.0.1" –Automatic
# DNS servers
$allDnsServer = @("10.0.0.1")
# DNS suffixes
$allDnsSuffixes = @("TESTDOMAIN.net")
# WINS servers
$allWinsServers = @()
New-SCStaticIPAddressPool -Name "TESTDOMAIN-Service-Network" -LogicalNetworkDefinition $logicalNetworkDefinition -Subnet "10.0.0.0/24" -IPAddressRangeStart "10.0.0.51" -IPAddressRangeEnd "10.0.0.75" -DefaultGateway $allGateways -DNSServer $allDnsServer -DNSSuffix "" -DNSSearchSuffix $allDnsSuffixes –RunAsynchronously
#Hyper-V Virtual Networks
$logicalNetwork = Get-SCLogicalNetwork -Name "TESTDOMAIN-Service-Network"
$vmNetwork = New-SCVMNetwork -Name "TESTDOMAIN-VMN" -LogicalNetwork $logicalNetwork -IsolationType "WindowsNetworkVirtualization" -CAIPAddressPoolType "IPV4" -PAIPAddressPoolType "IPV4"
Write-Output $vmNetwork
$subnet = New-SCSubnetVLan -Subnet "10.0.0.0/24"
New-SCVMSubnet -Name "Con-SN" -VMNetwork $vmNetwork -SubnetVLan $subnet
# bind VLAN with the Network Adapter
$vmHost = Get-SCVMHost -ComputerName "VMM01.TESTDOMAIN.net"
$vmHostNetworkAdapter = Get-SCVMHostNetworkAdapter -VMHost $vmHost #-Name "Intel 21140-Based PCI Fast Ethernet Adapter (Emulated)"
Set-SCVMHostNetworkAdapter -VMHostNetworkAdapter $vmHostNetworkAdapter -Description "" -AvailableForPlacement $true -UsedForManagement $true
$logicalNetwork = Get-SCLogicalNetwork -Name "TESTDOMAIN-Service-Network"
Set-SCVMHostNetworkAdapter -VMHostNetworkAdapter $vmHostNetworkAdapter -AddOrSetLogicalNetwork $logicalNetwork
Set-SCVMHost -VMHost $vmHost -RunAsynchronously -NumaSpanningEnabled $true
#Create a Private Cloud
$Guid = [System.Guid]::NewGuid()
Set-SCCloudCapacity -JobGroup $Guid -UseCustomQuotaCountMaximum $false -UseMemoryMBMaximum $false -UseCPUCountMaximum $false -UseStorageGBMaximum $false -UseVMCountMaximum $false -CustomQuotaCount 10 -MemoryMB 10240 -CPUCount 10 -StorageGB 386 -VMCount 10
$resources = @()
$resources += Get-SCLogicalNetwork -Name "TESTDOMAIN-Service-Network"
$resources += Get-SCLoadBalancer -Manufacturer "Microsoft"
$readonlyLibraryShares = @()
$readonlyLibraryShares += Get-SCLibraryShare | where { $_.LibraryServer.Name -eq "dc.TESTDOMAIN.net" -and $_.Name -eq "VMMLibrary" }
$addCapabilityProfiles = @()
$addCapabilityProfiles += Get-SCCapabilityProfile -Name "Hyper-V"
$Guid2 = [System.Guid]::NewGuid()
Set-SCCloud -JobGroup $Guid2 -RunAsynchronously -AddCloudResource $resources -AddReadOnlyLibraryShare $readonlyLibraryShares -AddCapabilityProfile $addCapabilityProfiles
$hostGroups = @()
$hostGroups += Get-SCVMHostGroup -Name "TESTDOMAIN"
New-SCCloud -VMHostGroup $hostGroups -Name "TESTDOMAIN-Cloud" -Description "" –RunAsynchronously
© Geeks with Blogs or respective owner