Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Workflow Create-MagentoNetwork
- {
- param
- (
- # Main Parameter
- [Parameter(Mandatory=$true)]
- [string]$SubscriptionID,
- # Main Parameter
- [Parameter(Mandatory=$true)]
- [string]$UserID,
- # Main Parameter
- [Parameter(Mandatory=$true)]
- [string]$NetworkName
- )
- $Creds = Get-AutomationPSCredential -Name 'CredBobby'
- $VMMServer = Get-AutomationVariable -Name 'VMMServer'
- $SCVMMConnection = Get-AutomationConnection -Name 'SCVMM Connect'
- $VmmServerName = $SCVMMConnection.ComputerName
- inlinescript {
- try {
- Import-Module virtualmachinemanager
- $subnetValue = "10.0.0.0/24"
- $subnetName = "MagentoSubnet"
- $dnsIP = "66.113.172.39"
- $ipAdressPoolName = "MagentoIPPool"
- $ipAddressRangeStart = "10.0.0.2"
- $ipAddressRangeEnd = "10.0.0.254"
- $vmNetworkName = $Using:NetworkName#"MagentoNetwork"
- $VMMobject = Get-SCVMMServer -ComputerName $Using:VMMServer -ForOnBehalfOf| Out-Null
- $UserRole = Get-SCUserRole | Where-Object {$_.Name -match $Using:SubscriptionID}
- $CloudObj = Get-SCCloud -Name "Fabric"
- $logicalNetwork = Get-SCLogicalNetwork -Cloud $CloudObj -Name "Provider Address Space"
- $vmNetwork = New-SCVMNetwork -Name $vmNetworkName -LogicalNetwork $logicalNetwork -OnBehalfOfUser $UserRole.Name -OnBehalfOfUserRole $UserRole -Owner $UserRole.Name
- $subnet = New-SCSubnetVLan -Subnet $subnetValue
- $vmSubnet = New-SCVMSubnet -Name $subnetName -VMNetwork $vmNetwork -SubnetVLan $subnet -OnBehalfOfUser $UserRole.Name -OnBehalfOfUserRole $UserRole
- $allDnsServer = @($dnsIP)
- $staticIPAddressPool = New-SCStaticIPAddressPool -Name $ipAdressPoolName `
- -VMSubnet $vmSubnet -Subnet $subnetValue -IPAddressRangeStart $ipAddressRangeStart `
- -IPAddressRangeEnd $ipAddressRangeEnd -DNSServer $allDnsServer `
- -RunAsynchronously -OnBehalfOfUser $UserRole.Name -OnBehalfOfUserRole $UserRole
- $gatewayDevice = Get-SCNetworkGateway -Name "CLRDWSG03"
- $VmNetworkGateway = Add-SCVMNetworkGateway -Name "MagentoNetwork_Gateway" -EnableBGP $false -NetworkGateway $gatewayDevice -VMNetwork $vmNetwork
- $externalIpPoolVar = Get-SCStaticIPAddressPool -Name "rdcloud-chi_Public01 Pool" #-ID "aa6e0e1e-7ed6-471d-9b50-d66e2096ef7e"
- $natConnection = Add-SCNATConnection -Name "MagentoNetwork_NatConnection" -VMNetworkGateway $VmNetworkGateway -ExternalIPPool $externalIpPoolVar
- } catch {
- Throw "Exception: $_"
- }
- } -PSComputerName $VmmServerName -PSCredential $Creds
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement