Execute SharePoint timer jobs on multiple computers

The Invoke-Command cmdlet runs commands on a local or remote computer and returns all output from the commands, including errors. By using a single Invoke-Command command, you can run commands on multiple computers.

To run a single command on a remote computer, use the ComputerName parameter. To run a series of related commands that share data, use the New-PSSession cmdlet to create a PSSession (a persistent connection) on the remote computer, and then use the Session parameter of Invoke-Command to run the command in the PSSession. To run a command in a disconnected session, use the InDisconnectedSession parameter. To run a command in a background job, use the AsJob parameter.

invoke-command -computername computer1,computer2 {asnp *sharepoint*;stop-service spadminv4; Start-SPAdminJob;start-service spadminv4}

This command stops the admin service, executes the timer jobs and starts the admin service.


Leave a Reply

Your email address will not be published. Required fields are marked *