Link to home
Start Free TrialLog in
Avatar of john lambert
john lambert

asked on

rdp system something wrong powerShell.exe' is not recognized

When I click on start then i  type powershell.exe nothing happen,i type again powershell without exe and appear this:
User generated image
when i start powershellscript.bat i receive this error
powershellscript.bat works perfect for my others rdp's

PS C:\Users\Dana> C:\Users\Dana\Desktop\SUCCES-LAST24h.bat
Batch cmd 1
'powerShell.exe' is not recognized as an internal or external command,
operable program or batch file.

Open in new window


I also have a scanner.bat i run it and must stop when finds this line ''-m '' but doesn't stop,works fine for my others 2 rdp's,so what's wrong with this one?how can i fix all this?
ASKER CERTIFIED SOLUTION
Avatar of jmcg
jmcg
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of john lambert
john lambert

ASKER

Target  and start is this:
my others 3 rdp's have indentical paths and works perfect
Target:%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe  
start in: %HOMEDRIVE%%HOMEPATH%

My script:
@echo off
pushd %~dp0

REM ... some CMD commands here ...
echo Batch cmd 1
call :callPS PSScript1
REM ... some CMD commands here ...
echo Batch cmd 2
call :callPS PSScript2
REM ... some CMD commands here ...
pause
popd
exit /b

:callPS label

powerShell.exe -ExecutionPolicy RemoteSigned -Command "$script = Get-Content '%~f0'; Invoke-Expression -Command ($script[(($script | select-string '::%1::').LineNumber)..(($script | select-string '::%1End::').LineNumber-2)] -join [environment]::NewLine)"


exit /b

----------------

::PSScript1::
write-host -foreground red Script1
Get-EventLog System | Where-Object {$_.EventID -eq "1074" -or $_.EventID -eq "6008" -or $_.EventID -eq "1076"} | ft Machinename, TimeWritten, UserName, EventID, Message -AutoSize -Wrap  | Out-File Reboot.txt
::PSScript1End::

----------------

::PSScript2::
write-host -foreground green Script2
::PSScript2End::

Open in new window

SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The target and start-in information that you provided look like what would appear in a shortcut but that is not the method you're invoking with. I agree with Qlemo that you need to see what your PATH variable looks like in the RDP session where the failure occurs.