Solved

rdp system something wrong powerShell.exe' is not recognized

Posted on 2016-10-03
6
30 Views
Last Modified: 2016-11-04
When I click on start then i  type powershell.exe nothing happen,i type again powershell without exe and appear this:
EasyCapture2.jpg
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?
0
Comment
Question by:john lambert
6 Comments
 
LVL 20

Accepted Solution

by:
jmcg earned 168 total points (awarded by participants)
ID: 41826046
The first thing to do to try to debug this situation is to locate powershell.exe on the target system and determine whether its directory is included in the PATH variable.
0
 

Author Comment

by:john lambert
ID: 41826100
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

0
 
LVL 69

Assisted Solution

by:Qlemo
Qlemo earned 166 total points (awarded by participants)
ID: 41826759
"Target" does not matter in this batch file. PowerShell.exe needs to be found via PATH (or special path set up in the reigstry). So you'll have to check that from inside the failing RDP session.
0
 
LVL 39

Assisted Solution

by:footech
footech earned 166 total points (awarded by participants)
ID: 41827034
Make sure that your Path environment variable hasn't gotten borked.  Check the PATH registry entry under HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment is of type REG_EXPAND_SZ.  If it is just REG_SZ it will not be evaluated/expanded and would cause problems.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 41829156
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.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
A brief introduction to what I consider to be the best editor for PowerShell.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now