SOLVED

switch between admin partitions in NetScaler

%3CLINGO-SUB%20id%3D%22lingo-sub-3085372%22%20slang%3D%22en-US%22%3Eswitch%20between%20admin%20partitions%20in%20NetScaler%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3085372%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI%20have%20a%20powershell%20script%20trying%20to%20find%20all%20servers%20that%20belong%20to%20the%20various%20partitions%20of%20several%20NetScaler%20IPs.%3C%2FP%3E%3CP%3EI%20can%20retrieve%20the%20servers%20list%20from%20default%20partition%2C%20but%20when%20I%20try%20to%20switch%20to%20the%20next%20admin%20partition%20I%20get%20the%20below%20error%20so%20I%20don't%20think%20the%20switch%20function%20performs%20well.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23DF0000%22%3E%3CSTRONG%3EInvoke-NSNitroRestApi%20%3A%20Cannot%20process%20argument%20transformation%20on%20parameter%20'Payload'.%20Cannot%20convert%20the%20%22PartitionACI%3C%2FSTRONG%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23DF0000%22%3E%3CSTRONG%3E%22%20value%20of%20type%20%22System.String%22%20to%20type%20%22System.Collections.Hashtable%22.%3C%2FSTRONG%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23DF0000%22%3E%3CSTRONG%3EAt%20D%3A%5CNetScaler_scripts%5CNetScaler_Populate_DB_Table_from_multiple_instances.ps1%3A401%20char%3A116%3C%2FSTRONG%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23DF0000%22%3E%3CSTRONG%3E%2B%20...%20-ResourceType%20nspartition%20-Payload%20%24Payload%5B%22partitionName%22%5D%20-Action%20...%3C%2FSTRONG%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23DF0000%22%3E%3CSTRONG%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~%3C%2FSTRONG%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23DF0000%22%3E%3CSTRONG%3E%2B%20CategoryInfo%20%3A%20InvalidData%3A%20(%3A)%20%5BInvoke-NSNitroRestApi%5D%2C%20ParameterBindingArgumentTransformationExceptio%3C%2FSTRONG%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23DF0000%22%3E%3CSTRONG%3En%3C%2FSTRONG%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23DF0000%22%3E%3CSTRONG%3E%2B%20FullyQualifiedErrorId%20%3A%20ParameterArgumentTransformationError%2CInvoke-NSNitroRestApi%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EMy%20switch%20function%20is%20this%20%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3Efunction%20SwitchPartition%7B%3CBR%20%2F%3E%5BCmdletBinding()%5D%3CBR%20%2F%3Eparam%20(%3CBR%20%2F%3E%5BParameter(Mandatory%3D%24true)%5D%20%5BPSObject%5D%24NSSession%2C%3CBR%20%2F%3E%5BParameter(Mandatory%3D%24true)%5D%20%5BPSObject%5D%24partition%3CBR%20%2F%3E)%3CBR%20%2F%3EBegin%20%7B%3CBR%20%2F%3EWrite-Verbose%20%22%24(%24MyInvocation.MyCommand)%3A%20Enter%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3EProcess%20%7B%3CBR%20%2F%3E%24Payload%20%3D%20%40%7B%7D%3CBR%20%2F%3E%24Payload%20%3D%20%40%7B%20partitionname%20%3D%20%24partition.partitionname%3B%20partitionid%20%3D%20%24partition.partitionid%3B%20maxbandwidth%3D%24partition.maxbandwidth%3B%20maxconn%20%3D%20%24partition.maxconn%3B%20maxmemlimit%20%3D%20%24partition.maxmemlimit%3B%20pmacinternal%20%3D%20%24partition.pmacinternal%20%7D%3CBR%20%2F%3EWrite-Host%20%24Payload%5B%22partitionname%22%5D%3CBR%20%2F%3E%24response%20%3D%20Invoke-NSNitroRestApi%20-NSSession%20%24NSSession%20-OperationMethod%20POST%20-ResourceType%20nspartition%20-Payload%20%24Payload%5B%22partitionname%22%5D%20-Action%20Switch%3CBR%20%2F%3E%7D%3CBR%20%2F%3EEnd%20%7B%3CBR%20%2F%3EWrite-Verbose%20%22%24(%24MyInvocation.MyCommand)%3A%20Exit%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3Eand%20I'm%20calling%20it%20with%20this%20command%20%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ESwitchPartition%20-NSSession%20%24NSSession%20-partition%20%24partition%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3Ewhere%20%24partition%20is%20this%20value%20that%20I%20get%20from%20a%20for%20loop%20I%20use%20to%20make%20sure%20that%20I%20enter%20all%20admin%20partitions%20%3A%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%40%7Bpartitionname%3DPartitionACI%3B%20partitionid%3D4%3B%20maxbandwidth%3D10240%3B%20maxconn%3D1024%3B%20maxmemlimit%3D10%3B%20pmacinternal%3DFalse%7D%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20have%20also%20tried%20to%20make%20payload%20variable%20like%20below%20%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSTRONG%3E%24Payload%20%3D%20%40%7B%7D%3CBR%20%2F%3E%24Payload%20%3D%20%40%7B%20partitionname%20%3D%20%24partition.partitionname%20%7D%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3Eand%3C%2FP%3E%3CP%3E%3CSTRONG%3E%24response%20%3D%20Invoke-NSNitroRestApi%20-NSSession%20%24NSSession%20-OperationMethod%20POST%20-ResourceType%20nspartition%20-Payload%20%24Payload%20-Action%20Switch%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Ebut%20again%20it%20doesn't%20work.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%20please%20%3F%3C%2FP%3E%3CP%3EThank%20you%20in%20advance.%3C%2FP%3E%3CP%3EVagelis%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3085372%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3124557%22%20slang%3D%22en-US%22%3ERe%3A%20switch%20between%20admin%20partitions%20in%20NetScaler%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3124557%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EFinally%20the%20issue%20wasn't%20in%20the%20switch%20function%20itself%20and%20the%20problem%20was%20resolved.%3C%2FP%3E%3CP%3EThank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E
New 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 (New 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.