0

I was trying to run some commands inside a powershell script. The scrpt execution doesn't show any error. Script content is like:

Export-PfxCertificate –Cert $selectedcert_CA –FilePath "C:\\Windows\\System32\\CA_cert.pfx" -Password $SecurePassword -Verbose -force

But when I execute the powershell script from ruby as: powershell.exe -file file.ps1 arg1 arg2

It displays file is created on path but I don't see any file created. If I run the same command separately (not in script just as a powershell command), it creates the file perfectly.

Is there any rights issue or I need to run the script with some permissions.

2
  • Any reason you're saving it to system32? That's a System/OS directory and it's bad practice to use them for file storage. As System folders are protected on modern versions of Windows, you need elevation to write to them. If you chose another directory, that's not in the Windows folder, you most likely won't have this issue anymore. Commented Dec 6, 2017 at 10:10
  • HI James, thanks for the reply. Changing the path also causes the same issue. In powershell it works fine, but as soon as i change to ruby interpreter & run the script like i mentioned above, it doesnt create the file. Commented Dec 6, 2017 at 10:36

1 Answer 1

1

This snippet will run the powershell console with administrative rights

PS> Start-Process powershell -Verb runAs
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.