2022-12-06 13:34:52 -05:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
function Get-NetboxVirtualMachine {
|
2021-07-23 22:06:42 +02:00
|
|
|
|
<#
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.SYNOPSIS
|
|
|
|
|
|
Obtains virtual machines from Netbox.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.DESCRIPTION
|
|
|
|
|
|
Obtains one or more virtual machines based on provided filters.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Limit
|
|
|
|
|
|
Number of results to return per page
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Offset
|
|
|
|
|
|
The initial index from which to return the results
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Query
|
|
|
|
|
|
A general query used to search for a VM
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Name
|
|
|
|
|
|
Name of the VM
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Id
|
|
|
|
|
|
Database ID of the VM
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Status
|
|
|
|
|
|
Status of the VM
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Tenant
|
|
|
|
|
|
String value of tenant
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Tenant_ID
|
|
|
|
|
|
Database ID of the tenant.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Platform
|
|
|
|
|
|
String value of the platform
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Platform_ID
|
|
|
|
|
|
Database ID of the platform
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Cluster_Group
|
|
|
|
|
|
String value of the cluster group.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Cluster_Group_Id
|
|
|
|
|
|
Database ID of the cluster group.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Cluster_Type
|
|
|
|
|
|
String value of the Cluster type.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Cluster_Type_Id
|
|
|
|
|
|
Database ID of the cluster type.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Cluster_Id
|
|
|
|
|
|
Database ID of the cluster.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Site
|
|
|
|
|
|
String value of the site.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Site_Id
|
|
|
|
|
|
Database ID of the site.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Role
|
|
|
|
|
|
String value of the role.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Role_Id
|
|
|
|
|
|
Database ID of the role.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Raw
|
|
|
|
|
|
A description of the Raw parameter.
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER TenantID
|
|
|
|
|
|
Database ID of tenant
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER PlatformID
|
|
|
|
|
|
Database ID of the platform
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER id__in
|
|
|
|
|
|
Database IDs of VMs
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.EXAMPLE
|
|
|
|
|
|
PS C:\> Get-NetboxVirtualMachine
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.NOTES
|
|
|
|
|
|
Additional information about the function.
|
|
|
|
|
|
#>
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[CmdletBinding()]
|
|
|
|
|
|
param
|
|
|
|
|
|
(
|
|
|
|
|
|
[Alias('q')]
|
|
|
|
|
|
[string]$Query,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Name,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16[]]$Id,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[object]$Status,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Tenant,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Tenant_ID,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Platform,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Platform_ID,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Cluster_Group,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Cluster_Group_Id,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Cluster_Type,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Cluster_Type_Id,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Cluster_Id,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Site,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Site_Id,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Role,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Role_Id,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-04-09 09:57:20 -04:00
|
|
|
|
[uint16]$Limit,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-04-09 09:57:20 -04:00
|
|
|
|
[uint16]$Offset,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[switch]$Raw
|
|
|
|
|
|
)
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|