I’m currently writing an automation that pulls data from a queue (an email address) and uses it as a parameter in a PowerShell script to update a security group. The PowerShell script needs to be run as a service account user so I am attempting to invoke PowerShell activity with the output of a read text file activity which starts PowerShell as the service account and then executes a ps script. here is the activity in question:
$PSFile = ‘\Scripts\AddAdobeCC_UiPath.ps1’
$credential = New-Object System.Management.Automation.PsCredential(“Domain\service.account”, (ConvertTo-SecureString “Password” -AsPlainText -Force))
Start-Process powershell -ArgumentList ‘-ExecutionPolicy’, ‘bypass’, $PSFile, ‘-UserEmailInput’, $UserEmailInput -Credential $credential
This is read into the “Input” variable and then passed to the invoke PowerShell activity.
for some reason, I keep getting “Invoke Power Shell: This command cannot be run due to the error: The directory name is invalid.” error. the service account user has permissions to the folder and script files.
my setup is identical to what has been posted at While running powershell using invoke activity it throws exception "windows powershell run as administrator" - #2 by loginerror
Can anyone offer any advice? I will upload my project file once i have worked out how.