An error occurred while parsing PowerShell Remote Command running

Source: Internet
Author: User

I'm glad to see that PowerShell Remoting is used to run commands on a remote machine. This is the trend of future technology, but it is also a bit complicated.

Only access local resources

Before starting to use the command, make sure that the command does not access non-local resources on the remote machine. If you run a Windows 7 or Windows 8 computer, use Remoting to transmit a command to computer B that is equipped with Windows Server 2008 or a later version, this command can be used to operate all resources on computer B. This is not allowed, especially for network access.

Why? This is because Remoting delegates your certificate to computer B, but for security reasons, computer B cannot delegate the certificate further.

To do this, you can use the CredSSP Protocol to implement multi-level authorization. Because there are many security factors, you need to be clear before you begin. You can browse more information from the free ebook PowerShell Remoting secret. The entire section in this ebook is about CredSSP.

Time Problems

Another possibility of a command is time. When you manually run a command locally, it takes some time to enter, press enter, and read the result. When you start to enter the next command, the previous command has been completed.

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 after the first command is executed. Especially when running External commands that start separate processes or threads.

To solve the problem, use Enter-PSSession to connect to the remote machine and manually run any commands that are being sent. If it is useful, use Invoke-Command when sending batch commands. Otherwise, you may encounter time problems.

You can use the Start-Sleep command to pause the shell or perform necessary checks, such as whether the file exists. Before executing other commands, sleep the shell and reproduce the check, and then start again.

External command Problems

Another possibility is that it only applies to external commands, rather than local PowerShell cmdlets, that is, remote machine errors explain your commands. In PowerShell v3, the external commands in the previous section were passed to cmd.exe using two broken numbers. This is usually used to solve the problem of external command syntax.

Remote rule

If you run the command through Remote Desktop Connection or directly logging on to the remote machine console from the server, this command will not run through PowerShell Remoting, at this time, you encountered an "environmental problem ".

Using Invoke-Command, Enter-PSSession, or other methods to remotely access the machine does not obtain a complete interactive desktop session as you log on to the console or remote desktop session. PowerShell does not execute the script of the profile and does not have a complete user environment. I have seen that a large number of commands are for this reason, but there may be some that do not.

If you have this problem, you can try to schedule your own commands on a remote machine. The Windows Task scheduler has a complete user account and cannot fix the problem, but it is worth a try.

If this does not solve the problem, it is stuck. If your command needs to run in a complete and interactive desktop environment, you must follow the above steps.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.