Powershell system.globalization.cultureinfo convert error

Hi Everyone,

I am trying to get the culture info of the Remote machine with poweshel on UiPath. Here is my PSScript:
“$password
$usernma
$hostname
$pw = convertto-securestring -AsPlainText -Force -String $password
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $usernma,$pw
$session = New-pssession -computername $hostname -credential $cred
Invoke-Command -Session $session -ScriptBlock {Get-Culture} -ArgumentList $localIpAddress
Remove-PSSession $session”

I get the following error: Invoke Power Shell: Unable to cast object of type ‘System.String’ to type ‘System.Globalization.CultureInfo’.

And when i change the TyoeArgument to String i get this error: Invoke Power Shell: Unable to cast object of type ‘System.Globalization.CultureInfo’ to type ‘System.String’ .

The code works perfectly fine on PS Console.


Can anyone help me please?

Did u import system.globalization namespace?

I did, still the same error.

The variables i have declared at the beginning of the code were causing trouble appearently. I deleted them and after making TypeArgument to System.Globalization.CultureInfo it works fine.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.