SOLVED

switch between admin partitions in NetScaler

Copper Contributor

Hello,

I have a powershell script trying to find all servers that belong to the various partitions of several NetScaler IPs.

I can retrieve the servers list from default partition, but when I try to switch to the next admin partition I get the below error so I don't think the switch function performs well.

 

Invoke-NSNitroRestApi : Cannot process argument transformation on parameter 'Payload'. Cannot convert the "PartitionACI
" value of type "System.String" to type "System.Collections.Hashtable".
At D:\NetScaler_scripts\NetScaler_Populate_DB_Table_from_multiple_instances.ps1:401 char:116
+ ... -ResourceType nspartition -Payload $Payload["partitionName"] -Action ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-NSNitroRestApi], ParameterBindingArgumentTransformationExceptio
n
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Invoke-NSNitroRestApi

 

My switch function is this :

 

function SwitchPartition{
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)] [PSObject]$NSSession,
[Parameter(Mandatory=$true)] [PSObject]$partition
)
Begin {
Write-Verbose "$($MyInvocation.MyCommand): Enter"
}
Process {
$Payload = @{}
$Payload = @{ partitionname = $partition.partitionname; partitionid = $partition.partitionid; maxbandwidth=$partition.maxbandwidth; maxconn = $partition.maxconn; maxmemlimit = $partition.maxmemlimit; pmacinternal = $partition.pmacinternal }
Write-Host $Payload["partitionname"]
$response = Invoke-NSNitroRestApi -NSSession $NSSession -OperationMethod POST -ResourceType nspartition -Payload $Payload["partitionname"] -Action Switch
}
End {
Write-Verbose "$($MyInvocation.MyCommand): Exit"
}
}

 

and I'm calling it with this command :

 

SwitchPartition -NSSession $NSSession -partition $partition

 

where $partition is this value that I get from a for loop I use to make sure that I enter all admin partitions :

@{partitionname=PartitionACI; partitionid=4; maxbandwidth=10240; maxconn=1024; maxmemlimit=10; pmacinternal=False}

 

I have also tried to make payload variable like below :

$Payload = @{}
$Payload = @{ partitionname = $partition.partitionname }

and

$response = Invoke-NSNitroRestApi -NSSession $NSSession -OperationMethod POST -ResourceType nspartition -Payload $Payload -Action Switch

but again it doesn't work.

 

Any ideas please ?

Thank you in advance.

Vagelis

3 Replies
best response confirmed by lampropo (Copper Contributor)
Solution

Hello,

Finally the issue wasn't in the switch function itself and the problem was resolved.

Thank you

@lampropo I am curious, - how did you resolve it?


Kind regards

Thomas Winther

Hello @ThomasWint we were given different user to make the SwitchPartition function and it worked.

1 best response

Accepted Solutions
best response confirmed by lampropo (Copper Contributor)
Solution

Hello,

Finally the issue wasn't in the switch function itself and the problem was resolved.

Thank you

View solution in original post