#Create NIC (called MyNicName)
$nicName = "myNicName"
$nic = New-AzureRmNetworkInterface -Name $nicName `
-ResourceGroupName $rgName `
-Location $location -SubnetId $azvnetworks.Subnets[0].Id `
-PublicIpAddressId $pip.Id `
-NetworkSecurityGroupId $aznsg.Id
Cannot index into a null array.
At line:1 char:1
+ $nic = New-AzureRmNetworkInterface -Name $nicName `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
ASKER
$azvnetworks = Read-Host -Prompt 'Enter Virtual Netwotk NAME (from above);'
ASKER
$vnet = New-AzureRmVirtualNetwork `
-Name $vnetName -ResourceGroupName $destinationResourceGroup `
-Location $location `
-AddressPrefix 10.0.0.0/16 `
-Subnet $singleSubnet
PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-AzureRmVirtualNetwork
WARNING: Breaking changes in the cmdlet 'Get-AzureRmVirtualNetwork' :
WARNING: - "The output type 'Microsoft.Azure.Commands.Network.Models.PSVirtualNetwork' is changing"
- The following properties in the output type are being deprecated :
'EnableVmProtection'
ResourceGroupName Name Location ProvisioningState EnableDdosProtection EnableVmProtection
----------------- ---- -------- ----------------- -------------------- ------------------
RG-Test-Lab Main-LAN uksouth Succeeded False False
ASKER
# $rgName = ...
# $location = ...
# $aznsg = ...
# $pip = ...
$azvnetworks = Get-AzureRmVirtualNetwork -Name 'Main-LAN'
#Create NIC (called MyNicName)
$nicName = "myNicName"
$nic = New-AzureRmNetworkInterface `
-Name $nicName `
-ResourceGroupName $rgName `
-Location $location `
-SubnetId $azvnetworks.Subnets[0].Id `
-PublicIpAddressId $pip.Id `
-NetworkSecurityGroupId $aznsg.Id
ASKER
$azvnetworks = Get-AzureRmVirtualNetwork (Read-Host -Prompt 'Enter Virtual Netwotk NAME (from above);')
(and not change anything on the other lines) if you do not need the name again, or if you do$azvnetworks = Read-Host -Prompt 'Enter Virtual Netwotk NAME (from above);'
$azvnetworksTemp = Get-AzureRmVirtualNetwork $azvnetworks
and then refer to that new var below that lines.
ASKER
ASKER
A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.
TRUSTED BY
Any decent programming language will not let you perform operation with a null object.
You see [0] (square brackets and a number within), it is a way for programming language to inspect members of an array.
I think your variable, $azvnetworks.Subnets is not populated with a value and as it is a null indexing operation cannot be performed and hence the error.
How are you getting $azvnetworks? Can you share the complete script?
Regards,
Chinmay.