Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

PS script works in console, but fails when called from cmd prompt

$
0
0

I have a script that quite simply sets ACLs on a few reg keys and a folder. Nothing too complicated at all. The script works perfectly when run from the console, but when called from a command prompt using the following command, it fails miserably:

powershell -command Get-Content "c:\temp\script.ps1" | powershell.exe -noprofile -

The script runs, but simple things fail, such as:

Get-Acl-Path"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

This works from the console but when called from a command prompt, I get "Get-Acl : Cannot find path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' because it does not exist

I've tried changing it to HKEY_LOCAL_MACHINE\... to no avail as well.

Is there something in the way of syntax that works under the PS prompt that doesn't work when called under the normal command prompt?

I know, I could drag out SubInACL and such, but was kind of hoping to get this to work.

By the way, this is running as the SYSTEM account.

Thanks.



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>