I run this Powershell command in:
powershell -command "\\mydrive\apps\automation\install_this.bat" -Verb runas
- Std user, nonelevated Powershell
- Elevated Powershell
- Non-elevated Powershell ISE (with F5 "run script")
and it runs successfully but when I run that above line in Powershell ISE as Admin, it complains that it doesn't recognize the path.
PS C:\Windows\system32> powershell -command "\\mydrive\apps\automation\install_this.bat" -Verb runas powershell : The system cannot find the path specified. At line:1 char:1 + powershell -command "\\mydrive\apps\automation\install_this.bat" - ...
So using F5 to "run script" is not the same as the way a one-liner powershell command runs. How do I get around that problem? It is most advantageous for me to get this to work in PS ISE elevated.. .
Here is my path:
C:\Users\dabbadoo>echo %PATH% C:\Windows\system32; C:\Windows; C:\Windows\System32\Wbem; C:\Windows\System32\WindowsPowerShell\v1.0\; C:\Users\dabbadoo\AppData\Local\Microsoft\WindowsApps;
Here is my $env:PSModulePath -split ";"
C:\Users\dabbadoo\Documents\WindowsPowerShell\Modules C:\Program Files\WindowsPowerShell\Modules C:\Windows\system32\WindowsPowerShell\v1.0\Modules
And finally, here is the
$PROFILE | Get-Member -MemberType noteproperty | select name Test-Path $Profile.AllUsersAllHosts Test-Path $Profile.AllUsersCurrentHost Test-Path $Profile.CurrentUserAllHosts Test-Path $Profile.CurrentUserCurrentHost
output from PS ISE and PS ISE As Admin (they were same):
Name ---- AllUsersAllHosts AllUsersCurrentHost CurrentUserAllHosts CurrentUserCurrentHost False False False False