
I have a cloud flow that calls a PA Desktop flow that executes a PowerShell script which extracts records from AD, writes them to a csv file, clears an SQL database table, and then writes the csv to the db. When I run this on my work laptop, it runs successfully in about 40-45 minutes. However, if I run it on my development PC or on our production PA server, it always times out. For both of the latter 2 servers, it seems to write out the csv file within minutes but then never touches the database (keep querying the db/never clears-stays at full record count). Since there are no error messages other than the time-out, I am "assuming" that it is failing on one of the SQL commands. The first SQL command clears the table - I've tried both DELETE and TRUNCATE options. Again, both work fine on the laptop - same time-out results on the other 2 platforms. I have compared SQL components on laptop vs PC and they are the same except for a 2008 SQL management objects and 2019 local db install on the PC. I've tried to have it time-out and go to the next step, but it wasn't successful. Any ideas on what is wrong or even how to produce an error message to point me in the right direction? Appreciate any feedback!
Have you tried running the same PowerShell script via the PowerShell app on Windows on the two target machines to see if it runs? Also, can you try simply running the SQL commands separately from those machines to verify that the machine has access to the related server and the user has the required permissions to run those commands?
Would it be possible to split the script into separate smaller scripts? Technically, most of what you do can be done with native PAD actions instead of using PowerShell. You could do that and only use PowerShell for things that PAD cannot do with native actions. This would simplify your script and make it easier to figure out what's up with it.
-------------------------------------------------------------------------
If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.
I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.