mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-12 17:32:29 +00:00
Add Basic usage in README.md (#30)
This commit is contained in:
parent
cb4e2f2f57
commit
ea75e796ef
1 changed files with 40 additions and 0 deletions
40
README.md
40
README.md
|
|
@ -14,6 +14,46 @@ This module is a wrapper for the [Netbox](https://github.com/netbox-community/ne
|
|||
2. Import module
|
||||
3. Connect to an API endpoint by using `Connect-NetboxAPI -Hostname netbox.example.com`
|
||||
|
||||
## Basic Commands
|
||||
|
||||
```powershell
|
||||
#Just adding a new IP
|
||||
New-NetboxIPAMAddress -Address 10.0.0.1/24 -Dns_name this.is.thedns.fqdn -Custom_Fields @{CustomFieldID="CustomFieldContent"} -Tenant 1 -Description "Description"
|
||||
|
||||
#Creating a new VM, add an interface and assign Interface IP
|
||||
function New-NBVirtualMachine
|
||||
{
|
||||
[CmdletBinding()]
|
||||
[Alias()]
|
||||
[OutputType([int])]
|
||||
Param
|
||||
(
|
||||
[string]$Name,
|
||||
[string]$Cluster,
|
||||
[string]$IP,
|
||||
[string]$tenant,
|
||||
[string]$VMNICName
|
||||
)
|
||||
|
||||
Begin
|
||||
{
|
||||
$NBCluster = Get-NetboxVirtualizationCluster -name $Cluster
|
||||
$NBTenant = Get-NetboxTenant -Name $tenant
|
||||
}
|
||||
Process
|
||||
{
|
||||
$vm = New-NetboxVirtualMachine -Name $Name -Cluster $NBCluster.id -Tenant $NBtenant.id
|
||||
$interface = Add-NetboxVirtualMachineInterface -Name $VMNICName -Virtual_Machine $vm.id
|
||||
|
||||
|
||||
$NBip = New-NetboxIPAMAddress -Address $IP -Tenant $NBtenant.id
|
||||
Set-NetboxIPAMAddress -Assigned_Object_Type virtualization.vminterface -Assigned_Object_Id $interface.id -id $NBip.id
|
||||
Set-NetboxVirtualMachine -Primary_IP4 $NBip.id -Id $vm.id
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
# Notes
|
||||
I started this project years ago with Powershell Studio using the built in deployment methods, learning Git, and learning PS best practices. So please forgive any "obvious" mistakes 😅
|
||||
Over time I have had to adjust my methods for deployment... change the design of functions, and refactor code as I learn new and better things.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue