Home » Microsoft » 70-687 » What should you do?
You administer 100 Windows 8.1 laptops, all of which have PowerShell Remoting enabled. You run the following command on a computer named Computer1.
Invoke-Command -filepath \Computer2ShareMyScript.ps1 -computer name Computer2 MyScriptl.psl fails to execute.
You verify that you are able to access it from the network.
You need to be able to execute MyScriptl.psl on Computer1.
What should you do?
A. Copy MyScriptl.psl to a local drive on Computer1 and run the Invoke-Command cmdlet on Computer1.
B. Run the Set-ExecutionPolicycmdlet on Computer1.
C. Run the Enter-PSSessioncmdlet on Computer1.
D. Run the Set-ExecutionPolicycmdlet on Computer2.
Correct Answer: A
Explanation/Reference:
Explanation:
http://technet.microsoft.com/en-us/library/hh849719.aspx
Invoke-Command
Runs commands on local and remote computers.
..
The Invoke-Command cmdlet runs commands on a local or remote computer and returns all output from the commands, including errors. With a single Invoke-Command command, you can run commands on multiple computers.
..
Parameters
..
-ComputerName<String[]>
Specifies the computers on which the command runs. The default is the local computer. When you use the ComputerName parameter, Windows PowerShell creates a temporary connection that is used only to run the specified command and is then closed.
..
-FilePath<String>
Runs the specified local script on one or more remote computers. Enter the path and file name of the script, or pipe a script path to Invoke-Command. The script must reside on the local computer or in a directory that the local computer can access. Use the ArgumentList parameter to specify the values of parameters in the script.
..
Further Information:
http://technet.microsoft.com/en-us/library/ee176961.aspx
Using the Set-ExecutionPolicy Cmdlet
The Set-ExecutionPolicy cmdlet enables you to determine which Windows PowerShell scripts (if any) will be allowed to run on your computer. Windows PowerShell has four different execution policies:
Restricted - No scripts can be run. Windows PowerShell can be used only in interactive mode. AllSigned - Only scripts signed by a trusted publisher can be run. RemoteSigned - Downloaded scripts must be signed by a trusted publisher before they can be run. Unrestricted - No restrictions; all Windows PowerShell scripts can be run. To assign a particular policy simply call Set-ExecutionPolicy followed by the appropriate policy name.
http://technet.microsoft.com/en-us/library/hh849812.aspx
Set-ExecutionPolicy
The Set-ExecutionPolicy cmdlet changes the user preference for the Windows PowerShell execution policy.
The execution policy is part of the security strategy of Windows PowerShell. It determines whether you can load configuration files (including your Windows PowerShell profile) and run scripts, and it determines which scripts, if any, must be digitally signed before they will run.
http://technet.microsoft.com/en-us/library/hh849707.aspx
Enter-PSSession
The Enter-PSSession cmdlet starts an interactive session with a single remote computer. During the session, the commands that you type run on the remote computer, just as though you were typing directly on the remote computer. You can have only one interactive session at a time.