public/New-FreeNasIscsiPortal.ps1
function New-FreenasIscsiPortal { [CmdletBinding()] [Alias()] [OutputType([int])] Param ( [Parameter (Mandatory = $true)] $IpPortal, [Parameter (Mandatory = $false)] [string]$Port = 3260 , [Parameter (Mandatory = $false)] [string]$Comment ) Begin { Get-FreeNasStatus switch ( $Script:status) { $true { } $false {Break} } } Process { $Uri = "http://$script:SrvFreenas/api/v1.0/services/iscsi/portal/" $input = @($IpPortal + ":" + $Port) $IpPortalPort = @() foreach ($item in $input) { $IpPortalPort += $item } $Obj = [Ordered]@{ iscsi_target_portal_ips = $IpPortalPort iscsi_target_portal_comment = $Comment } $post = $Obj |ConvertTo-Json $response = invoke-RestMethod -method Post -body $post -Uri $Uri -WebSession $script:Session -ContentType "application/json" } End {} } |