Use Power. Shell to Run Programs on Remote Computers Running programs on remote computers is a common administrative task, and there are a number of techniques available to accomplish it. As I described in the web- exclusive article . First, Jt. exe worked on both XP and Win. K, whereas Schtasks didn't exist on Win. K. Second, Jt. exe had a . Power. Shell can use PSCredential objects, which securely store passwords. Power. Shell pipelining makes working with multiple computers relatively easy. In Power. Shell, you can output custom objects with whatever properties are needed. However, I was annoyed to discover that, at least from Windows 7, you can't connect to remote XP systems using either the Task. Service or Schtasks method. As Figure 1 shows, both methods return an Access is denied error. Before I show you how to use the new Power. Shell script, however, I need to describe the Jt. Start- Program. ps. You can download this utility from ftp: //ftp. After you extract the Jt. Path. You only need Jt. Path on the computer on which you run Start- Program. For that reason, I designed Start- Program. Jt. exe command that contains the parameters shown in Table 1. For example, Figure 2 shows some sample output strings, one of which contains an error message. How to Shut Down and Reboot Remote PCs via the Command.How to use System Information (MSINFO32). Some command-line switches available for Windows XP are no longer. Command options that are. How to Remotely Restart a Windows Machine Through Command Line. To remotely restart a Windows machine through command line, follow these. Log into a remote Windows computer as an Administrator. However, the output strings make parsing difficult, especially if you need to execute a Jt. Start- Program. ps. Jt. exe errors for you, reporting errors when appropriate. Process p = Process.Start(psi); System.Threading.Thread.Sleep. Open a Command Prompt of Remote Computer. Shutdown Your Computer or a Remote PC via Command Prompt Most of us shutdown our computers using the power button given in the Start menu. Some of us use the physical power button on our. This will start the command prompt. First, you don't need to type passwords in clear text on the command line. Second, Start- Program. Jt. exe command- line parameters shown in Table 1. Third, Start- Program. Finally, it outputs objects that can be filtered, sorted, and so on. After you extract the script, you should put it in the same Path as Jt. You can omit the - Computer. Name parameter name if you put the computer names first on the command line. You can specify a period (.) or the string localhost to refer to the current computer. This parameter also supports pipeline input (i. You can specify a date, a time, or both. If you specify only a date, the time will be midnight. If you specify only a time, the date will be the current day. Because the parameter is a Date. Time object, you can specify the date and time in any valid format. Note that for remote computers, this parameter refers to the date and time on the remote computer, not the computer on which you run the script. You can also specify a shell script (i. This parameter can include a path to a network location if the credentials you specify have the appropriate permissions. You shouldn't include the program's command- line arguments in the - Program parameter. If the program needs command- line arguments, you need to use the - Parameters parameter. The parameter needs to be enclosed in double quotes (. However, the string must not contain embedded double quotes due to a limitation in Jt. Otherwise, the OS will decide the program's working directory. Note that if you're running a program on a remote computer, the working directory is relative to the remote computer, not the current computer. This parameter can be useful for troubleshooting. This set of credentials will be used to start the scheduled task. If you don't specify this parameter, Start- Program. Due to the aforementioned limitation in Jt. If you specify the - Verbose parameter, the script outputs the exact Jt. Jt. exe. You can use the verbose output as needed to diagnose problems. Next, the script executes that command and captures Jt. Finally, the script outputs a PSObject object that contains the following properties: Computer. Name (the computer on which the task was scheduled) Task. Name (the scheduled task's name, which the script generates based on the program name and the date and time the task was scheduled) Start. Time (the date and time the task will run) Command. Line (the program name and its arguments) Keep. Task (True or False, based on whether the - Keep. Task parameter was specified) Result (0 for success, non- zero hexadecimal code for error) Figure 3 shows a sample command that uses the - Verbose parameter and the resulting output object. Note that Start- Program. This means that a clear- text copy of the password is temporarily available in memory while the script creates and executes the Jt. Thus, there's a remote possibility of password exposure if a rogue process has access to this memory or if Windows swaps the memory to disk. In other words, if you run Start- Program. Power. Shell session, Jt. However, if you run Start- Program. Power. Shell session, Jt. This caveat applies only to scheduling tasks on the current computer. If you're running a non- elevated Power. Shell session but you're logged on using an account that's a member of the Administrators group on a remote computer, the task will run elevated. Start- Program. ps.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
September 2016
Categories |