Hello everyone,
I am trying to execute a PowerShell command on multiple remote servers using UiPath’s Invoke Power Shell activity. The command I want to run works perfectly when executed directly in PowerShell using Invoke-Command
i tried using :
[string]$username = "username"
[string]$password = "password"
[string[]]$servers = "server1","server2"
# Convert plain password to SecureString
$secPassword = ConvertTo-SecureString $password -AsPlainText -Force
# Create PSCredential object
$cred = New-Object System.Management.Automation.PSCredential ($username, $secPassword)
# Invoke command on remote servers
Invoke-Command -ComputerName $servers -Credential $cred -ErrorAction Stop -ScriptBlock {
Get-Date -Format 'yyyy-MM-dd HH:mm:ss zzz'
}
the script run correctly in powershell but doesn’t execute with invoke powershell in UiPath also i want to use the credentials from orchestrator.
I would really appreciate any guidance on this.