Running powershell script in commandline

Best practices, code snippets for common functionality, examples, and guidelines.
KimVW
Posts: 6
Joined: Mon Feb 01, 2021 1:06 pm

Running powershell script in commandline

Post by KimVW » Thu Oct 07, 2021 1:44 pm

I might have a silly question here...

When I manually start cmd and run my powershell script to get all installed office apps then the script runs fine and my result is shown.

When I do exactly the same process via Ranorex it fails every time!

What am I missing here, what am I doing wrong?
pwsincommandline.png
2021-10-07_14-43-45.png
tnx!
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Running powershell script in commandline

Post by odklizec » Thu Oct 07, 2021 2:06 pm

Hi,

Unfortunately, it's hard to tell what's wrong, without seeing the ps1 file. Have you tried to create a batch file, which will execute the powershell commands (instead of typing the commands to cmd window)? Also, are you running the test/Ranorex Studio as admin or non-admin?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

KimVW
Posts: 6
Joined: Mon Feb 01, 2021 1:06 pm

Re: Running powershell script in commandline

Post by KimVW » Tue Jan 24, 2023 3:30 pm

Instead of starting the script with the Action 'run application' I decided to start up my Windows explorer and simply double click the file there... it's a little bit of more steps, but it's working fine

Baxter
Posts: 11
Joined: Wed Jun 29, 2022 10:03 pm

Re: Running powershell script in commandline

Post by Baxter » Mon Feb 06, 2023 4:29 pm

this drove me nuts for a while until I found this in the weeds of stackoverflow:

https://stackoverflow.com/questions/131 ... om-c-sharp
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted