this powershell module using PHPIPAM rest api to operate PHPIPAM tasks ,powershell version suggest 3.0 or above.
this module works on powershell core 6.0 and above now ,and the test environment is mainly on linux and powershell core
# if you just want to use it , install PSPHPIPAM module
Install-Module -Name PSPHPIPAM
# list command this module provide
get-command -module PSPHPIPAM
# get help for a command
get-help Get-PhpIpamSubnet -full
# just get example of a command
get-help Get-PhpIpamSubnet -examples
# if you want to extend the module functions, read Docs\* and Tests\* under this project to gain idears.
No support and test with PHPIPAM 'encryped' Application security mode.
该powershell 模组使用PHPIPAM REST API来操作PHPIPAM的一些任务。建议powershell 3.0 或者更高版本,目前已经支持powershell core 6.0,最新的测试环境已经移到linux 环境,并且主要使用powershell core 6.x 进行测试.
Docs 目录放置说明还有截图,而且模块的每个内置的函数也尽量包含了example 和说明,你可以使用get-help command 来获取帮助
Tests 目录放置pester 测试文件,该测试文件针对vagrant 搭建的phpipam 开发环境进行测试.
PSPHPIPAM 目录放置该模块的主要的函数\包括基础模块函数还有其他扩展的函数.如果你要扩充模块,请添加命令到Functions\Public ,参考其他的函数命令,比如Functions\Public|TestIdears
Nginx 是PhpIpam 测试开发环境使用的nginx 配置文件及证书,我会使用vagrant 来创建一个PHPipam 的环境,其使用docker 搭建了一个可用的Phpipam环境
- buildenv.*
可以用来创建PHPIPAM 开发测试环境,需要安装vagrant,virtualbox 参考 也可以直接使用docker-compose
Read the docs:
The functions in this module mainly used powershell advanced function feature (the function which contains [cmdletbinding()]
, so when you encounter errors ,you can add the -debug
switch to see what's goging on there,you can add your write-debug
expression to the function to see more information if you want.
Debug like this
New-PhpIpamSession -useCredAuth -PhpIpamApiUrl http://127.0.0.1/api -AppID script2 -userName admin -password password -debug
if you want to see raw network requests ,you can use below hacks to capture api request and response using a proxy
for example you have a proxy listening at http://127.0.0.1:8088
import-module PSPHPIPAM
$module=Get-Module PSPHPIPAM
# execute custom hack code in the module env
# hack the default proxy value of invoke-restmethod command
$module.Invoke({$PSDefaultParameterValues['invoke-restmethod:proxy']='http://127.0.0.1:8088'})
# display $PSDefaultParameterValues in the module env
$module.Invoke({$PSDefaultParameterValues})
# test your code here
Update-PhpIpamAddress -params @{id=279;description="test3";ip="127.0.0.254"}
# the above code has not return and no error ,even using -debug param like below
Update-PhpIpamAddress -params @{id=279;description="test3";ip="127.0.0.254"} -debug
# but the log in proxy can see the detail
# {"code":400,"success":false,"message":"IP address cannot be changed","time":0.002}
# we can see invoke-webrequest and invoke-restmethod will report simple 400 error and we can not see the error detail
# the root cause of 400 return code is because. ip property is not use when patch address object
# the phpipam API doc will prove this