Open laboiteajb opened 4 years ago
No problem! The structure for the query is a hash table, separate the pieces with a semi-colon.
Get-nbInterface -query @{name='1/1'; device = 'CR'}
about_Hash_Tables should help with anything more advanced.
perfect thank you
I have another question (sorry)
I can't inject the result into a variable: $var = (Get-nbInterface -Query @ {name = '1/1'; device = 'CR'})
the variable contains the set of interfaces
@laboiteajb That space between @
and {
is invalid, is it a copy paste error or in your code?
> @ { key = 'value' }
ParserError:
Line |
1 | @ { key = 'value' }
| ~
| Unrecognized token in source text.
> @{ key = 'value' }
Name Value
---- -----
key value
@evilensky yes is it a copy paste error
I have good news, it works
$var = (Get-nbInterface -Query @{name = '1/1'; device = 'CR'})
Write-Host $var
if later I want to modify a value
$var.name = "1/p" | Set-nbInterface
Here is the result
applet de commande Set-nbInterface à la position 1 du pipeline de la commande
Fournissez des valeurs pour les paramètres suivants :
object :
PS C:\Users\jb> Get-nbObject
applet de commande Get-nbObject à la position 1 du pipeline de la commande
Fournissez des valeurs pour les paramètres suivants :
Resource :
what is the object and the resources?
set-nbinterface isn't accepting pipeline input -
Set-NbInterface -Object $var
get-nbobject is a generic way of retrieving any object, you should use a specific get like Get-NBVirtualMachine
instead.
Get-NBVirtualMachine
just wraps Get-NBObject -resource 'virtualization/virtual-machine'
for example.
Hello,
It's been a while since I touched the powershell, sorry for my level
I will want to create a script to add the switch configuration files to netbox.
is it possible to indicate several parameters to Get-nbInterface -query exemple : Get-nbInterface -query @{name='1/1'}, @{device = 'CR'}
thx