NetboxPS/Functions/Virtualization/VirtualMachine/Get-NetboxVirtualMachine.ps1

144 lines
2.8 KiB
PowerShell
Raw Normal View History

2022-12-06 13:34:52 -05:00

2020-03-23 12:18:01 -04:00
function Get-NetboxVirtualMachine {
<#
2020-03-23 12:18:01 -04:00
.SYNOPSIS
Obtains virtual machines from Netbox.
2020-03-23 12:18:01 -04:00
.DESCRIPTION
Obtains one or more virtual machines based on provided filters.
2020-03-23 12:18:01 -04:00
.PARAMETER Limit
Number of results to return per page
2020-03-23 12:18:01 -04:00
.PARAMETER Offset
The initial index from which to return the results
2020-03-23 12:18:01 -04:00
.PARAMETER Query
A general query used to search for a VM
2020-03-23 12:18:01 -04:00
.PARAMETER Name
Name of the VM
2020-03-23 12:18:01 -04:00
.PARAMETER Id
Database ID of the VM
2020-03-23 12:18:01 -04:00
.PARAMETER Status
Status of the VM
2020-03-23 12:18:01 -04:00
.PARAMETER Tenant
String value of tenant
2020-03-23 12:18:01 -04:00
.PARAMETER Tenant_ID
Database ID of the tenant.
2020-03-23 12:18:01 -04:00
.PARAMETER Platform
String value of the platform
2020-03-23 12:18:01 -04:00
.PARAMETER Platform_ID
Database ID of the platform
2020-03-23 12:18:01 -04:00
.PARAMETER Cluster_Group
String value of the cluster group.
2020-03-23 12:18:01 -04:00
.PARAMETER Cluster_Group_Id
Database ID of the cluster group.
2020-03-23 12:18:01 -04:00
.PARAMETER Cluster_Type
String value of the Cluster type.
2020-03-23 12:18:01 -04:00
.PARAMETER Cluster_Type_Id
Database ID of the cluster type.
2020-03-23 12:18:01 -04:00
.PARAMETER Cluster_Id
Database ID of the cluster.
2020-03-23 12:18:01 -04:00
.PARAMETER Site
String value of the site.
2020-03-23 12:18:01 -04:00
.PARAMETER Site_Id
Database ID of the site.
2020-03-23 12:18:01 -04:00
.PARAMETER Role
String value of the role.
2020-03-23 12:18:01 -04:00
.PARAMETER Role_Id
Database ID of the role.
2020-03-23 12:18:01 -04:00
.PARAMETER Raw
A description of the Raw parameter.
2020-03-23 12:18:01 -04:00
.PARAMETER TenantID
Database ID of tenant
2020-03-23 12:18:01 -04:00
.PARAMETER PlatformID
Database ID of the platform
2020-03-23 12:18:01 -04:00
.PARAMETER id__in
Database IDs of VMs
2020-03-23 12:18:01 -04:00
.EXAMPLE
PS C:\> Get-NetboxVirtualMachine
2020-03-23 12:18:01 -04:00
.NOTES
Additional information about the function.
#>
2020-03-23 12:18:01 -04:00
[CmdletBinding()]
param
(
[Alias('q')]
[string]$Query,
2020-03-23 12:18:01 -04:00
[string]$Name,
2023-07-28 16:17:23 -04:00
[uint64[]]$Id,
2020-03-23 12:18:01 -04:00
[object]$Status,
2020-03-23 12:18:01 -04:00
[string]$Tenant,
[uint64]$Tenant_ID,
2020-03-23 12:18:01 -04:00
[string]$Platform,
[uint64]$Platform_ID,
2020-03-23 12:18:01 -04:00
[string]$Cluster_Group,
[uint64]$Cluster_Group_Id,
2020-03-23 12:18:01 -04:00
[string]$Cluster_Type,
[uint64]$Cluster_Type_Id,
[uint64]$Cluster_Id,
2020-03-23 12:18:01 -04:00
[string]$Site,
[uint64]$Site_Id,
2020-03-23 12:18:01 -04:00
[string]$Role,
[uint64]$Role_Id,
2020-04-09 09:57:20 -04:00
[uint16]$Limit,
2020-04-09 09:57:20 -04:00
[uint16]$Offset,
2020-03-23 12:18:01 -04:00
[switch]$Raw
)
process {
if ($null -ne $Status) {
$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
}
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $uri -Raw:$Raw
2020-03-23 12:18:01 -04:00
}
}