-
Notifications
You must be signed in to change notification settings - Fork 18
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
Adding a new Subnet #12
Comments
using a hashtable like @{description="description";mask=24} to replace using a psobject and add props with add-member.
获取 Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: andrewchown <[email protected]>
Sent: Friday, April 12, 2019 7:53:08 PM
To: yoke88/PSPHPIPAM
Cc: Subscribed
Subject: [yoke88/PSPHPIPAM] Adding a new Subnet (#12)
Hi there i'm trying to add a new subnet but getting an error. I used Get-PhpIpamSubnetByID to copy the object but no luck. Any help would be great:
Create the new object:
$newsubnet =@()
$object = New-Object CTypeName PSObject
$object | Add-Member CMemberType NoteProperty CName subnet CValue '10.10.10.0'
$object | Add-Member CMemberType NoteProperty CName mask CValue '24'
$object | Add-Member CMemberType NoteProperty CName description CValue 'bbbb'
$object | Add-Member CMemberType NoteProperty CName sectionId CValue '1'
#$object | Add-Member CMemberType NoteProperty CName linked_subnet CValue '0'
$object | Add-Member CMemberType NoteProperty CName vlanId CValue '0'
$object | Add-Member CMemberType NoteProperty CName vrfId CValue '0'
$object | Add-Member CMemberType NoteProperty CName masterSubnetId CValue '170'
$object | Add-Member CMemberType NoteProperty CName nameserverId CValue '0'
$object | Add-Member CMemberType NoteProperty CName showName CValue '0'
#$object | Add-Member CMemberType NoteProperty CName permissions CValue
$object | Add-Member CMemberType NoteProperty CName DNSrecursive CValue '0'
$object | Add-Member CMemberType NoteProperty CName DNSrecords CValue '0'
$object | Add-Member CMemberType NoteProperty CName allowRequests CValue '0'
$object | Add-Member CMemberType NoteProperty CName scanAgent CValue '0'
$object | Add-Member CMemberType NoteProperty CName pingSubnet CValue '0'
$object | Add-Member CMemberType NoteProperty CName discoverSubnet CValue '0'
$object | Add-Member CMemberType NoteProperty CName isFolder CValue '0'
$object | Add-Member CMemberType NoteProperty CName isFull CValue '0'
$object | Add-Member CMemberType NoteProperty CName state CValue '0'
$object | Add-Member CMemberType NoteProperty CName threshold CValue '0'
#$object | Add-Member CMemberType NoteProperty CName firewallAddressObject CValue '0'
$object | Add-Member CMemberType NoteProperty CName location CValue '4'
$object | Add-Member CMemberType NoteProperty CName device CValue '0'
$object | Add-Member CMemberType NoteProperty CName tag CValue '0'
$object | Add-Member CMemberType NoteProperty CName resolveDNS CValue '0'
$newsubnet += $object
Try to use the object:
New-PhpIpamSubnet -Params $newsubnet
Error:
[image]<https://user-images.githubusercontent.com/22792216/56035322-bdbb8d80-5d21-11e9-9799-a27b10d0ec18.png>
New-PhpIpamSubnet : Cannot validate argument on parameter 'Params'. The "$_ -is [system.collections.hashtable]" validation script for the argument with value "@{subnet=10.10.10.0; mask=24;
description=bbbb; sectionId=1; vlanId=0; vrfId=0; masterSubnetId=170; nameserverId=0; showName=0; DNSrecursive=0; DNSrecords=0; allowRequests=0; scanAgent=0; pingSubnet=0; discoverSubnet=0;
isFolder=0; isFull=0; state=0; threshold=0; location=4; device=0; tag=0; resolveDNS=0}" did not return a result of True. Determine why the validation script failed, and then try the command
again.
At line:1 char:27
* New-PhpIpamSubnet -Params $newsubnet
*
~~~~~~~~~~
* CategoryInfo : InvalidData: (:) [New-PhpIpamSubnet], ParameterBindingValidationException
* FullyQualifiedErrorId : ParameterArgumentValidationError,New-PhpIpamSubnet
―
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#12>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ADAB8pQsHACdGczmOSARyHUY8XJtY3dKks5vgHOkgaJpZM4cr9RB>.
|
Hi, thanks for the reply. Still getting an error: Command: Invoke-PhpIpamExecute : {"code":400,"success":0,"message":"Request is not valid","time":0.001}
|
https://phpipam.net/api/#subnets
reference the api details to see which params and the param type can be used.
if the param need number format, but you give an string type, the error will occur
获取 Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: andrewchown <[email protected]>
Sent: Friday, April 12, 2019 8:54:01 PM
To: yoke88/PSPHPIPAM
Cc: yoke88; Comment
Subject: Re: [yoke88/PSPHPIPAM] Adding a new Subnet (#12)
Hi, thanks for the reply. Still getting an error:
Command:
new-PhpIpamSubnet -params @{subnet='10.10.10.0';mask='24';description='test';sectionId='1';vlanId='0';vrfId='0';masterSubnetId='170';nameserverId='0';showName='0';DNSrecursive='0';DNSrecords='0';allowRequests='0';scanAgent='0';pingSubnet='0';discoverSubnet='0';isFolder='0';isFull='0';threshold='0';location='0';device='0';tag='0';resolveDNS='0'}
[image]<https://user-images.githubusercontent.com/22792216/56038639-548c4800-5d2a-11e9-93aa-38cb95dafe72.png>
Invoke-PhpIpamExecute : {"code":400,"success":0,"message":"Request is not valid","time":0.001}
At C:\TMP\PSPHPIPAM\Functions\Subnets.ps1:191 char:14
* ... if($(Invoke-PhpIpamExecute -method post -controller subnets -p ...
*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
* FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-PhpIpamExecute
―
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#12 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ADAB8gGJE3NmioRYcpAGfdnyAQhu7Cdtks5vgIHpgaJpZM4cr9RB>.
|
and there are two functions to aid you work with get-* object and reuse it to create a new object or update a object.
you must reference the api doc, to confirm which param can be used and the param type. common mistakes are post wrong or unnecessary param or the param type is wrong and you can reference #5 |
Hi thanks again for the help. I've tried the below command and many variations on it but still no luck. new-PhpIpamSubnet -params @{masterSubnetId=170;description="test";subnet="10.10.10.0";mask=24;sectionId=1;location=4} Do you have a way to find out which properties are mandatory? Do you have an example of a subnet POST command you have working? I can't see a log in PHPIPAM to try and fault find this. |
only sectionid is mandatory,you must read the api doc. if you have trouble add -debug switch for the command you execute. for example
|
Hey there, any chance you could send me a an example piece of code to write
a subnet? I haven't succeeded yet.
Andy
…On Tue, 16 Apr 2019, 10:46 yoke88, ***@***.***> wrote:
only sectionid is mandatory,you must read the api doc. if you have trouble
add -debug switch for the command you execute.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AVvIGDTQHU8U14PiEdqChRmHPM7cnld3ks5vhZwKgaJpZM4cr9RB>
.
|
New-PhpIpamSubnet -Params @{sectionId=1;subnet='192.168.10.0';mask=24}
PS /> $subnet=Get-PhpIpamAllSubnets|?{$_.subnet -eq '192.168.10.0' -and $_.sectionid -eq 1 }
PS /> $subnet
id : 8
subnet : 192.168.10.0
mask : 24
sectionId : 1
description :
linked_subnet :
firewallAddressObject :
vrfId :
masterSubnetId : 0
allowRequests : 0
vlanId :
showName : 0
device : 0
permissions : {"3":"1","2":"2"}
pingSubnet : 0
discoverSubnet : 0
resolveDNS : 0
DNSrecursive : 0
DNSrecords : 0
nameserverId : 0
scanAgent :
isFolder : 0
isFull : 0
tag : 2
threshold : 0
location :
editDate :
lastScan :
lastDiscovery :
usage : @{used=0; maxhosts=254; freehosts=254; freehosts_percent=100; Offline_percent=0; Used_percent=0;
Reserved_percent=0; DHCP_percent=0}
PS /> $UpdatedSubnet=@{id=$subnet.id;description="this was a test"}
PS /> Update-PhpIpamSubnet -Params $UpdatedSubnet
True
PS /> Remove-PhpIpamSubnetByID -ID $subnet.id
True
|
Hi there i'm trying to add a new subnet but getting an error. I used Get-PhpIpamSubnetByID to copy the object but no luck. Any help would be great:
Create the new object:
$newsubnet =@()
$object = New-Object –TypeName PSObject
$object | Add-Member –MemberType NoteProperty –Name subnet –Value '10.10.10.0'
$object | Add-Member –MemberType NoteProperty –Name mask –Value '24'
$object | Add-Member –MemberType NoteProperty –Name description –Value 'bbbb'
$object | Add-Member –MemberType NoteProperty –Name sectionId –Value '1'
#$object | Add-Member –MemberType NoteProperty –Name linked_subnet –Value '0'
$object | Add-Member –MemberType NoteProperty –Name vlanId –Value '0'
$object | Add-Member –MemberType NoteProperty –Name vrfId –Value '0'
$object | Add-Member –MemberType NoteProperty –Name masterSubnetId –Value '170'
$object | Add-Member –MemberType NoteProperty –Name nameserverId –Value '0'
$object | Add-Member –MemberType NoteProperty –Name showName –Value '0'
#$object | Add-Member –MemberType NoteProperty –Name permissions –Value
$object | Add-Member –MemberType NoteProperty –Name DNSrecursive –Value '0'
$object | Add-Member –MemberType NoteProperty –Name DNSrecords –Value '0'
$object | Add-Member –MemberType NoteProperty –Name allowRequests –Value '0'
$object | Add-Member –MemberType NoteProperty –Name scanAgent –Value '0'
$object | Add-Member –MemberType NoteProperty –Name pingSubnet –Value '0'
$object | Add-Member –MemberType NoteProperty –Name discoverSubnet –Value '0'
$object | Add-Member –MemberType NoteProperty –Name isFolder –Value '0'
$object | Add-Member –MemberType NoteProperty –Name isFull –Value '0'
$object | Add-Member –MemberType NoteProperty –Name state –Value '0'
$object | Add-Member –MemberType NoteProperty –Name threshold –Value '0'
#$object | Add-Member –MemberType NoteProperty –Name firewallAddressObject –Value '0'
$object | Add-Member –MemberType NoteProperty –Name location –Value '4'
$object | Add-Member –MemberType NoteProperty –Name device –Value '0'
$object | Add-Member –MemberType NoteProperty –Name tag –Value '0'
$object | Add-Member –MemberType NoteProperty –Name resolveDNS –Value '0'
$newsubnet += $object
Try to use the object:
New-PhpIpamSubnet -Params $newsubnet
Error:
New-PhpIpamSubnet : Cannot validate argument on parameter 'Params'. The "$_ -is [system.collections.hashtable]" validation script for the argument with value "@{subnet=10.10.10.0; mask=24;
description=bbbb; sectionId=1; vlanId=0; vrfId=0; masterSubnetId=170; nameserverId=0; showName=0; DNSrecursive=0; DNSrecords=0; allowRequests=0; scanAgent=0; pingSubnet=0; discoverSubnet=0;
isFolder=0; isFull=0; state=0; threshold=0; location=4; device=0; tag=0; resolveDNS=0}" did not return a result of True. Determine why the validation script failed, and then try the command
again.
At line:1 char:27
The text was updated successfully, but these errors were encountered: