How to schedule software installation with PowerShell

Under certain circumstances the installation of software can only take place at a specific time. This article describes the establishing of a scheduled installation on the localhost and on remote hosts.

Scheduling an installation job for the localhost

I am logged on server dc01. The goal is to install the windowsfeature Windows-Server-Backup at 10:30 am. First, I have to provide a trigger. Then I need a Scheduled Job. So, I run in PowerShell ISE

$trigger=New-JobTrigger -Once -At "7/28/2017 10:30 AM"
Register-ScheduledJob -Name WSBackupInstall -ScriptBlock {Install-WindowsFeature -Name Windows-Server-Backup} -Trigger $trigger


To make sure the job was running and completed successfully use Get-Job.

Get-Job | Select-Object *


Scheduling an installation job for a remote host

To do the same on a remote host simply add the command Invoke-Command and the parameter computername. Make sure, that both hosts are in the same domain. If they don´t share the same domain you have to configure them as Trusted Hosts. More about Trusted Hosts in  my article: How to configure Trusted Hosts for PowerShell Remote Sessions.

I am logged on server dc01. I want to schedule a job on server02.

Invoke-Command -ComputerName server02 -ScriptBlock {Register-ScheduledJob -Name WSBackupInstall -ScriptBlock {Install-WindowsFeature -ComputerName server02 -Name Windows-Server-Backup} -Trigger (New-JobTrigger -Once -At "7/28/2017 10:30 AM")}

To make sure, that the software was installed on the remote computer run

Invoke-Command -ComputerName server02 {Get-Job | Select-Object PSComputerName,PSBeginTime,PSEndtime; Get-WindowsFeature Windows-Server-Backup | Select-Object Name,PSComputerName,Installstate}


See also

For scheduling the automatic start of PowerShell at logon see my article Configuring the automatic start of Powershell at every logon.

If you want to automatically restart an application when it was accidentially closed , see:

PowerShell: How to automatically restart applications when they are closed

5 replies »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.