Siva
(siva)
August 15, 2019, 12:21am
1
Hi,
Below script gives me list of IPs. I want to store them in a octopus variable. So that I can pass the variable to my next step as input. If its not possible then what is the best way to pass this list of output to my next step.
$vnet = Get-AzureRmVirtualNetwork -Name “XXXXXXXXX” -ResourceGroupName “YYYYYYYYY”
$networkID = “10.0.0.”
$vhd1_ip_list = new-object System.Collections.Arraylist
$j = 0
For ($I=1; $i -lt 5; $i++)
{
$IP = $networkID + $i
$Address = Test-AzureRmPrivateIPAddressAvailability -VirtualNetwork $vnet -IPAddress $IP
If ($Address.Available –eq $False) { Write-Host “$IP is not available” -ForegroundColor Red
$vhd1_ip_list.Add($IP)
$j++
}
else { Write-Host “$IP is available” -ForegroundColor Green}
}
$available_ips = @(Foreach ($a in $vhd1_ip_list)
{
Write-Host $a
})
Write-Host $available_ips
Regards,
-Siva
Greetings Siva! Octopus Deploy supports the use of Output Variables, see https://octopus.com/docs/deployment-process/variables/output-variables for documentation on how to use this.
Hope this helps!
Siva
(siva)
August 15, 2019, 12:27am
4
Thanks for your quick response.
I have gone through his…this is what I did and please correct me if I’m doing it incorrect
step 1:
$vnet = Get-AzureRmVirtualNetwork -Name “XXXXXXXXX” -ResourceGroupName “YYYYYYYYY”
$networkID = “10.0.0.”
$vhd1_ip_list = new-object System.Collections.Arraylist
$j = 0
For ($I=1; $i -lt 5; $i++)
{
$IP = $networkID + $i
$Address = Test-AzureRmPrivateIPAddressAvailability -VirtualNetwork $vnet -IPAddress $IP
If ($Address.Available –eq $False) { Write-Host “$IP is not available” -ForegroundColor Red
$vhd1_ip_list.Add($IP)
$j++
}
else { Write-Host “$IP is available” -ForegroundColor Green}
}
$available_ips = @(Foreach ($a in $vhd1_ip_list)
{
Write-Host $a
})
Write-Host $available_ips
Set-OctopusVariable -name “available_ips” -value “Passed”
step 2:
Write-Host “Printg from IP availability step”
$available_ips = $OctopusParameters[“Octopus.Action[ip availability].Output.available_ips”]
Write-Host $available_ips
regards,
-Siva
May I assume the name of step 1 is ip availability? Since it has a space in the name, you may need to surround it with single quotes.
Siva
(siva)
August 15, 2019, 12:48am
6
I tried changing that…but it still doesn’t print the values which are stored in $available_ips in step 2
step 1:
$vnet = Get-AzureRmVirtualNetwork -Name “XXXXXXXXX” -ResourceGroupName “YYYYYYYYY”
$networkID = “10.0.0.”
$vhd1_ip_list = new-object System.Collections.Arraylist
$j = 0
For ($I=1; $i -lt 5; $i++)
{
$IP = $networkID + $i
$Address = Test-AzureRmPrivateIPAddressAvailability -VirtualNetwork $vnet -IPAddress $IP
If ($Address.Available –eq $False) { Write-Host “$IP is not available” -ForegroundColor Red
$vhd1_ip_list.Add($IP)
$j++
}
else { Write-Host “$IP is available” -ForegroundColor Green}
}
$available_ips = @(Foreach ($a in $vhd1_ip_list)
{
Write-Host $a
})
Write-Host $available_ips
Set-OctopusVariable -name “available_ips” -value $available_ips
step 2:
Write-Host “Printg from IP availability step”
$available_ips = $OctopusParameters[“Octopus.Action[ipavailability].Output.available_ips”]
Write-Host $available_ips
Regards,
-Siva
Siva
(siva)
August 15, 2019, 4:13am
7
Thanks, I figured it out.
Excellent! Please let me know if I can be of further assistance
system
(system)
Closed
September 14, 2019, 3:27pm
9
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.