Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if there is an error in the remote running command of PowerShell?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to do PowerShell remote operation command error", the content is simple and easy to understand, clear organization, I hope to help you solve doubts, let Xiaobian lead you to study and learn "PowerShell remote operation command error" this article bar.

Access only local resources

Before you start using it, make sure that commands do not access non-local resources on remote machines. If you run a Windows 7 or Windows 8 computer, use Remoting to send a command to computer B running Windows Server 2008 or later, and that command will operate all resources on computer B. This is not allowed, especially access to the network.

Why not? This is because Remoting delegates your certificate to Computer B, but for security reasons Computer B does not allow further delegation of certificates.

If you need to do this, you can implement multi-level authorization by using the CredSSP protocol. Because there are many safety factors, you need to be clear before you start. You can browse for more information from the free ebook Secrets of PowerShell Remoting, which has an entire chapter on CredSSP.

matter of time

Another possibility of command is the question of time. When you manually run a command locally, it takes a certain amount of time to type, click "Enter," and read the results. Before you start typing the next command, the previous command has already been executed.

This is not necessarily the case when you send a batch of commands to a remote machine. The machine can go to the next command before *** command execution is complete. Especially when running external commands that start separate processes or threads.

To resolve the problem, connect to the remote machine using Enter-PSSession and manually run whatever command you are trying to send. If this works, switch to Invoke-Command when sending bulk commands. Otherwise, you'll have a time problem.

There are several ways you can solve the problem: you can pause the shell with the Start-Sleep command; you can also perform necessary checks, such as whether files exist; and you can put the shell to sleep and repeat the checks before executing other commands, and then continue to start.

External command problem

Another possibility that applies only to external commands and not local PowerShell cmdlets is that the remote machine misinterprets your commands. In PowerShell v3, the preceding external command uses two dashes ("--") to tell the shell to pass to Cmd.exe as it is, even without parsing. This is often used to solve external command syntax problems.

remote rule

If you successfully run the command via a remote desktop connection or log in directly to the console of the remote machine from the server, the command will not run via PowerShell Remoting, and you encounter an "environmental problem."

Remote entry into the machine using Invoke-Command, Enter-PSSession, or other methods does not result in a full interactive desktop session like logging into a console or remote desktop session. PowerShell does not execute scripts for profiles, and there is no complete user environment. I see a lot of orders for this reason, but there may be some that don't have this problem.

If you have this problem, you can try scheduling your own commands on a remote machine. Windows Task Scheduler has a full user account and is not guaranteed to fix the problem, but it is worth a try.

The above is "PowerShell remote command error how to do" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report