Skip to content

Instantly share code, notes, and snippets.

@sochan1
sochan1 / Get-AzureRmVirtualNetworkSubnetConfig
Created October 24, 2016 10:06
Get-AzureRmVirtualNetworkSubnetConfig
PS C:\Windows\system32> Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork "VNET1" -Name "subnet1"
Get-AzureRmVirtualNetworkSubnetConfig : Cannot bind parameter 'VirtualNetwork'. Cannot convert the "VNET1" value of type "System.String" to type
"Microsoft.Azure.Commands.Network.Models.PSVirtualNetwork".
At line:1 char:55
+ Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork "VNET1" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-AzureRmVirtualNetworkSubnetConfig], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.Network.GetAzureVirtualNetworkSubnetConfigCommand
@sochan1
sochan1 / vmcreate
Created October 20, 2016 16:53
vmcreate
$location='east us2'
$resourceGroup='TEST-RG'
$vmname='TESTVM'
$bootstorageaccount='TESTSTORAGE'
$vhduri= 'https://TESTSTORAGE.blob.core.windows.net/TESTVM.vhd'
$OSDISKNAME = "TESTVMOSDISK"
$size='Standard_D3_v2'
$ip='10.0.1.9'
Select-AzureRmSubscription -SubscriptionName "TEST-RG"
@sochan1
sochan1 / vmcreation
Created October 17, 2016 11:28
vmcreation
$vmName="Testvm02"
$vmSize= 'Standard_F8s'
$resourceGroupName="Test-RG"
$vnet="ELNK-UAT-VNET-10.141.0.0"
$location="EAST US 2"
$subnet="Test-Subnet"
$nicname=$vmname + '-NIC'
$ipname=$vmname + '-NIC-IP'
$vhduri = "https://Test.blob.core.windows.net/test.vhd"
$OsdiskName="Test"
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string",
"metadata": {
"description": "Name of the VM"
}
},
@sochan1
sochan1 / vmcreation
Created October 10, 2016 08:48
createm vm from existing vhd
$resourceGroup="test-DR-RG"
$location = "East US2"
$vmname='test-sc-cd02'
#Collecting required parameters for creating VM
$StorageAccountName='testvhdstorage02'
$vnet=Get-AzureRmVirtualNetwork -ResourceGroupName $resourceGroup
$subnetname = $vnet.Subnets.name
$vnetname=$vnet.Name
$subnetid=Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork $vnet -Name $subnetname
@sochan1
sochan1 / Vnet with no subnetid
Created September 8, 2016 14:18
Vnet with no subnetid
New-AzureRmResourceGroup -Name $resourcegroup -Location $location
New-AzureRmVirtualNetwork -ResourceGroupName $resourcegroup -Name VNET1 -Location $location -AddressPrefix 192.168.0.0/16
$vnet = Get-AzureRmVirtualNetwork -ResourceGroupName $resourcegroup -Name VNET1
Add-AzureRmVirtualNetworkSubnetConfig -Name $SubnetFront -VirtualNetwork $vnet -AddressPrefix 192.168.1.0/24
Add-AzureRmVirtualNetworkSubnetConfig -Name $SubnetBack -VirtualNetwork $vnet -AddressPrefix 192.168.2.0/24
configuration NewPullServer
{
param
(
[string[]]$ComputerName = ‘vms03’
)
Import-DSCResource -ModuleName xPSDesiredStateConfiguration