Im attempting to test the functionality of a much larger script, but I have run into an issue with my test. The test is simply getting a user from AD. I have written the following to a text file.
Import-Module activedirectoy
Get-ADUser {{samaccountname}} —> (not a variable - the user’s samaccount name typed in)
I used the “Read Text File” activity to convert the txt file containing the script to a string. Then used the “Invoke Power Shell” activity using the string variable in the Command Text parameter. I also checked IsScript. I am getting the below error.
Error:
Invoke Power Shell: Unable to cast object of type ‘Microsoft.ActiveDirectory.Management.ADUser’ to type ‘System.Management.Automation.PSObject’.
If you are trying to do AD automation using UiPath, its better to sue the default UiPath powershell package for this. All the functionalities are covered as different activities and its easy to use.