Invoke PowerShell Activity error : A parameter cannot be found that matches parameter name Un

Script :

“param([Parameter(Mandatory=$true)] $Botusername,[Parameter(Mandatory=$true)] $Password,[Parameter(Mandatory=$true)] $Un)
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
$PathToPowerShell64bit = Get-ChildItem -Path $Env:Windir\WinSxS | Where-Object {$_.FullName -match ‘amd64_microsoft-windows-powershell-exe’}
$PowerShell64bitExe = Get-ChildItem -Path $PathToPowerShell64bit.FullName -Filter PowerShell.exe | Select-Object -ExpandProperty FullName
& $PowerShell64bitExe -file $FilePath -Un $Un -Botusername $Botusername -Password $Password”

Error details : Invoke Power Shell: PowerShell command errors:

: A parameter cannot be found that matches parameter name ‘Un’.
+ CategoryInfo : InvalidArgument: (:slight_smile: [MSOnline.ps1], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : NamedParameterNotFound,MSOnline.ps1

I’m actually passing all as parameters : Botusername, Password, Un but unable to find root cause for this.

Hi @Sonalk,

Please refer this tutorial : How to Integrate PowerShell with UiPath- Step by Step guide - News / Tutorials - UiPath Community Forum

You probably will need to also check if the code/script runs in your PowerShell instance before running it in UiPath.

The error is in the -Un $Un PowerShell is not able to identify -Un as an argument in the $PowerShell64bitExe. Your piped object and Select-Object is where the error originates.

1 Like

@jeevith : Script is working fine when i am running MSOnline.ps1 script manually. I’ve passed all three parameters manually to PowerShell screen and got the expected output.

I am assuming that we can pass three mandatory parameters in Invoke PowerShell activity. If i replace this command "Get-MsolUser -UserPrincipalName $Un | select Licenses " with different command “Get-MsolAccountSku” then it is working fine.

This is something related to issue with path for MSOnline.ps1. Issue is not with script or passed parameters actually

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