- Inside MATLAB -> type !powershell in the command window. This will open power shell in interactive mode. From there you can execute your powershell commands.
- Use 'system' command in MATLAB and add the powershell command inside the 'system' function parenthesis.
How do you access Powershell in MATLAB interactively
조회 수: 33 (최근 30일)
이전 댓글 표시
I am trying to leverage the "-AsSecureString" feature in Powershell to hide some confidential text strings for future use. I am struggling at the first step. The command in cmd is
powershell "$a=Read-Host -Prompt 'enter your input' -AsSecureString"
which works well from cmd.
When I call the same command with the system function in MATLAB, I get an empty interface on which I can type anything but cannot exit. There is no prompt, and my input string is visible and not secure. Getting this to work would be ideal for my problem, and I can get this to work from cmd. unfortunately, calling it from MATLAB just does not work. Is there a work around for this?
댓글 수: 0
답변 (2개)
Rahul
2025년 1월 24일
I understand that you wish to run powershell commands from MATLAB and are facing the issue of getting an exmpty interface. As suggested in the following MATLAB Answers, you consider following the given workarounds:
Here are examples:
% Workaround 1
!powershell
% Workaround 2
system(powershell "$a=Read-Host -Prompt 'enter your input' -AsSecureString")
Refer to the following MathWorks documentation to know more:
Thanks.
댓글 수: 0
Walter Roberson
2025년 1월 24일
Powershell implies that you are using Windows. In that case you can use System.Diagnostics.Process to configure input and output to a Powershell process. See the outline at https://www.mathworks.com/matlabcentral/answers/2002092-system-diagnostics-process-doesn-t-execute-all-commands-in-external-file#answer_1280947
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Performance and Memory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!