-
Notifications
You must be signed in to change notification settings - Fork 597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add get dtl VNet function #664
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -713,6 +713,43 @@ function Set-AzDtlLabSharedImageGallery { | |
} | ||
} | ||
|
||
function Get-AzDtlVirtualNetworks { | ||
[CmdletBinding()] | ||
param( | ||
[parameter(Mandatory=$true, ValueFromPipeline=$true, HelpMessage="Lab object to get the Virtual Network from")] | ||
[ValidateNotNullOrEmpty()] | ||
$Lab, | ||
|
||
[parameter(Mandatory=$false, ValueFromPipeline=$true, HelpMessage="If set, get the Expanded Resource from the std VNet object")] | ||
$ExpandResource | ||
) | ||
|
||
begin {. BeginPreamble} | ||
process { | ||
try { | ||
foreach($lab in $Lab) { | ||
|
||
$lab = $lab | Get-AzDtlLab | ||
|
||
$dtlLabVNets = Get-AzureRmResource ` | ||
-ResourceGroupName $lab.ResourceGroupName ` | ||
-ResourceType Microsoft.DevTestLab/labs/virtualnetworks ` | ||
-ResourceName $lab.Name ` | ||
-ApiVersion 2018-09-15 | ||
|
||
if ($ExpandResource) { | ||
foreach($dtlLabVNet in $dtlLabVNets) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can use a more PowerShell-like syntax here like $dtlLabVNets | ForEach-Object { .... } |
||
Get-AzureRmVirtualNetwork -ResourceGroupName $dtlLabVNet.ResourceGroupName -Name $dtlLabVNet.Name -ExpandResource $ExpandResource | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If ExpandResource isn't passed in - does anything get returned from this commandlet? I would think we should have the Lab VNets always returned, and if ExpandResource is passed in, we can inject another property that contains the underlying VNet resource? There's an example for Getting VMs & Extended status in the library... |
||
} | ||
} | ||
} | ||
} catch { | ||
Write-Error -ErrorRecord $_ -EA $callerEA | ||
} | ||
} | ||
end {} | ||
} | ||
|
||
function Get-AzDtlLabSharedImageGalleryImages { | ||
[CmdletBinding()] | ||
param( | ||
|
@@ -3183,6 +3220,8 @@ New-Alias -Name 'UnClaim-AzureRmDtlVm' -Value Invoke-AzDtlVmUnClaim | |
New-Alias -Name 'Dtl-NewEnvironment' -Value New-AzDtlLabEnvironment | ||
New-Alias -Name 'Dtl-GetEnvironment' -Value Get-AzDtlLabEnvironment | ||
|
||
New-Alias -Name 'Dtl-GetVirtualNetworks' -Value Get-AzDtlVirtualNetworks | ||
|
||
Export-ModuleMember -Function New-AzDtlLab, | ||
Remove-AzDtlLab, | ||
Get-AzDtlLab, | ||
|
@@ -3220,7 +3259,8 @@ Export-ModuleMember -Function New-AzDtlLab, | |
Get-AzDtlVmArtifact, | ||
Import-AzDtlCustomImageFromUri, | ||
Get-AzDtlCustomImage, | ||
New-AzDtlCustomImageFromVm | ||
New-AzDtlCustomImageFromVm, | ||
Get-AzDtlVirtualNetworks | ||
|
||
Export-ModuleMember -Alias * | ||
#endregion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a value from the pipeline? I think only the Lab would be brought in via the pipeline?