Invoke powershell Activity property

Hello all,
I want to use PowerShell activity of UiPath.
I passed the script in command text prop : it is not working
I created a file and tried calling it : no luck
could you please help me in invoking the script which includes variables as well.

error : Unable to cast object of type ‘system.string’ to type ‘system.management.automation.PSObject’

InvalidCastException

Hi

I have tried creating a file using Powershell command as:

  • CommandText- “New-Item D:\AnEmptyFile.txt -ItemType file”

  • IsScript- True

It gives the following error:Unable to cast object of type ‘System.IO.FileInfo’ to type ‘system.management.automation.PSObject

Then I changed TypeArgumentProperty to System.IO.FileInfo and it executed successfully. We can also store this Info of created file in output variable.

In your case,you can try to change your type argument to string because your command generates some string output which you can store and use further in your workflow.

after running the activity , in output it is giving me the type which I mentioned in the property.