Product Documentation

Using Installation Manager PowerShell Cmdlets

Oct 09, 2015

Cmdlet Summary

This reference assumes you are familiar with using PowerShell. The Installation Manager cmdlets support the standard PowerShell common parameters, such as WhatIf.

To import the Installation Manager PowerShell cmdlets, either:
  • Type Add –PSSnapIn IMAdmin at the PowerShell command prompt, or
  • Import the cmdlets automatically by adding asnp IMAdmin to the PowerShell profile profile.ps1
This topic provides brief options descriptions. For complete cmdlet syntax, type Get-Help cmdlet-name at the PowerShell prompt.
Cmdlet Description
Get-IMServer Lists servers in a XenApp farm
Create-IMMSITask Schedules installation of an MSI or MSP package
Create-IMTask Schedules installation of a Task Scheduler file
Create-IMCMDTask Schedules installation of a command-line task
Get-IMTask Obtains success or failure status information about scheduled tasks
Remove-IMTask Removes a scheduled task

Get-IMServer

Lists the servers in a specific XenApp farm.

You can specify the following options:
Option Description
-farm IP address or DNS name of the MFCOM farm object. If this option is omitted, the local server is used.
-folder Path to the server folder in the farm, in the format \folder1\folder2.
For example, the following cmdlet lists servers in the XenApp farm with a DNS name of XenAppFarmIN.
Get-IMServer -farm XenAppFarmIN  
-folder Servers\TargetFolder

Create-IMMSITask

Schedules installation of an MSI or MSP package on target servers. You can specify the following options:
Option Description

-name

(Required) Unique task name.

-msi

(Required) Path to the installation package. The file must be accessible by the task management computer. The cmdlet checks if this file exists; if it does not exist, an error is displayed.

-targets

(Required) Target servers where the package will be installed. Specify one of the following:
  • A comma-delimited list of individual servers by DNS name
  • An object containing Name attributes (as returned by the Get-IMServer cmdlet)

-mst

List of paths to MSI transform files. The files must be accessible by the task management computer. The cmdlet checks if this file exists; if it does not exist, an error is displayed.

-schedule

Date and time the installation task will run. Specify one of the following:
  • A date in the format DD/MM/YYYY and the time in 24-hour format HH:MM:SS, enclosed in single or double quotes
  • now to launch the task immediately

-logoffSessions

Forces users to log off the server before launching the installation. (You can use the -message option to prompt users to save their work and log off.)

-disablelogon

Prevents users from logging on during the installation.

-reboot

Restarts the server after installation. (You can use the -timeout option to specify how long to wait after installation completes to restart the server, and the -message option to specify a message to be sent to connected sessions before the restart.)

-message

Sends a message to all connected sessions before a logoff or restart. This option is valid with the -logoffSessions and -reboot options.

-timeout

Specifies the number of minutes that connected sessions have until a server restart.

-update

Overwrites any existing task with the same task name. If this option is omitted and another task with the same name exists, the task fails.

-prepareUnc

Specifies a shared folder, in UNC format, that Installation Manager uses to transfer files to target servers. Installation Manager automatically copies the specified MSI, MSP, and transform (MST) files to this folder and assigns read permission from the target servers to the file share. You must have sufficient rights to set UNC permissions. The folder must be accessible by all specified target servers.

-log

Path to a file or XML object where the success or failure status of the installation on each target server is logged.

-retrytime

If a target server cannot be contacted, this option specifies how long (in seconds) Installation Manager will retry the installation task. If you specify a retry time, you must also specify a retry interval.

-retryinterval

If a target server cannot be contacted, this option specifies how often (in seconds) Installation Manager will retry the installation task. If you specify a retry interval, you must also specify a retry time.

For example, the following cmdlet distributes an MSI package (located at c:localfolder\myapp.msi), using a transform (located at c:\localfolder\myapp_silent.mst), and a shared folder (\\fileserver\im), on the target servers XAWRK1, XAWRK2, and XAWRK3. The task will launch the first day of October 2010 at 11:50 p.m. Users will be alerted with a message before the installation begins. Users will not be able to log on during the installation, and the server will be restarted ten minutes after the installation completes. If a target server is busy, Installation Manager will retry every 10 seconds for a total of 60 seconds.
Create-IMMSITask -name Installmyapp  
-targets XAWRK1,XAWRK2,XAWRK3 -msi c:\localfolder\myapp.msi  
-mst c:\localfolder\myapp_silent.mst  
-schedule '01/10/2010 23:50:00'  
-prepareUNC \\fileserver\im -retrytime 60 -retryinterval 10  
-message "Please save your work and logoff.  
Server will reboot for maintenance." -timeout 10  
-logoffsessions -reboot

Create-IMTask

Schedules installation of a Task Scheduler file. You should be familiar with using Task Scheduler. Use the Task Scheduler MMC to create the Task Scheduler file. Installation Manager passes the Task Scheduler file directly to Windows Task Scheduler; it is not transferred using the file share.

You can specify the following options:
Option Description

-name

(Required) Unique task name.

-task

(Required) Path to the XML file or PowerShell XML object to install. The XML schema must follow Task Scheduler 2.0 specifications.

-targets

(Required) Target servers where the file will be installed. Specify one of the following:
  • A comma-delimited list of individual servers by DNS name
  • An object containing Name attributes (as returned by the Get-IMServer cmdlet)

-update

Overwrites any existing task with the same task name. If this option is omitted and another task with the same name exists, the task fails.

-retrytime

If a target server cannot be contacted, this option specifies how long (in seconds) Installation Manager will retry the installation task. If you specify a retry time, you must also specify a retry interval.

-retryinterval

If a target server cannot be contacted, this option specifies how often (in seconds) Installation Manager will retry the installation task. If you specify a retry interval, you must also specify a retry time.

-log

Path to a file or XML object where the success or failure status of the installation on each target server is logged.

For example, the following cmdlet distributes a Windows Task Scheduler file (located at C:\task.xml) that runs a backup script (named Backuptask) on the target servers (XAWRK1, XAWRK2, and XAWRK3). If a target server is busy, Installation Manager will retry every 10 seconds for a total of 60 seconds. If a task with the same name already exists, its definition will be overwritten. Success/failure status of the installations will be logged to C:\log.xml.
Create-IMTask -name Backuptask  
-targets XAWRK1,XAWRK2,XAWRK3 -task c:\task.xml -update 
-retrytime 60 -retryinterval 10 -log c:\log.xml

Create-IMCMDTask

Schedules installation of a command-line task. You can specify the following options:
Option Description

-name

(Required) Unique task name.

-command

(Required) Command-line operation to run on the target servers.

-targets

(Required) Target servers where the package will be installed. Specify one of the following:
  • A comma-delimited list of individual servers by DNS name
  • An object containing Name attributes (as returned by the Get-IMServer cmdlet)

-schedule

Date and time the installation task will run. Specify one of the following:
  • A date in the format DD/MM/YYYY and the time in 24-hour format HH:MM:SS, enclosed in single or double quotes
  • now to launch the task immediately

-update

Overwrites any existing task with the same task name. If this option is omitted and another task with the same name exists, the task fails.

-prepareUnc

Specifies a shared folder, in UNC format, that Installation Manager can use to transfer files to target servers. Installation Manager automatically transfers files to this folder and updates the folders' ACL to ensure all servers have read access to it. You must have sufficient rights to set UNC permissions.

-retrytime

If a target server cannot be contacted, this option specifies how long (in seconds) Installation Manager will retry the installation task. If you specify a retry time, you must also specify a retry interval.

-retryinterval

If a target server cannot be contacted, this option specifies how often (in seconds) Installation Manager will retry the installation task. If you specify a retry interval, you must also specify a retry time.

-log

Path to a file or XML object where the success or failure status of the installation on each target server is logged.

For example, the following cmdlet schedules installation of a task (named Installnotepad) using the command-line notepad.exe, on target servers XAWRK1, XAWRK2, and XAWRK3. If a target server is busy, Installation Manager will retry every 10 seconds for a total of 60 seconds. If a task with the same name already exists, its definition will be overwritten. Success/failure status of the installations will be logged to C:\log.xml.
Create-IMCMDTask -name Installnotepad  
-command notepad.exe -targets XAWRK1,XAWRK2,XAWRK3 -update  
-retrytime 60 -retryinterval 10 -log C:\log.xml

Get-IMTask

Obtains success or failure status about scheduled task installations. You can specify the following options.
Option Description

-targets

(Required) Target servers for which you want task installation information. Specify one of the following:
  • A comma-delimited list of individual servers by DNS name
  • An object containing Name attributes (as returned by the Get-IMServer cmdlet)

-name

Task name.

-fromdate

Starting date of the interval for which you want status.

-todate

End date of the interval for which you want status.

-log

XML path of the log file. If this option is omitted, the status is displayed in the PowerShell console.

For example, the following cmdlet displays status in the PowerShell console about the installation of the task named Installnotepad on target servers XAWRK1 and XAWWRK2.
Get-IMTask -targets XAWRK1,XAWRK2  
-name Installnotepad

Remove-IMTask

Removes a task scheduled on target servers. You can specify the following options:
Option Description

-targets

(Required) Target servers on which you want to remove a scheduled task. Specify one of the following:
  • A comma-delimited list of individual servers by DNS name
  • An object containing Name attributes (as returned by the Get-IMServer cmdlet)

-name

(Required) Task name.

-retrytime

If a target server cannot be contacted, this option specifies how long (in seconds) Installation Manager will retry the task removal. If you specify a retry time, you must also specify a retry interval.

-retryinterval

If a target server cannot be contacted, this option specifies how often (in seconds) Installation Manager will retry the task removal. If you specify a retry interval, you must also specify a retry time.

-log

Path to a file or XML object where the success or failure status of the task removal on each target server is logged.

For example, the following cmdlet removes the task named Installnotepad from target servers XAWRK1 and XAWRK2. If a target server is busy, Installation Manager will retry every 10 seconds for a total of 60 seconds. Success/failure status of the task removal will be displayed in the PowerShell console.
Remove-IMTask -targets XAWRK1,XAWRK2  
-name Installnotepad -retrytime 60 -retryinterval 10