Invoke remote device actions via PowerShell

This will be a short blog post about a the newly introduced WMI class, in the latest service pack, called SMS_DeviceAction. As I’m currently working on a new tool to remotely manage mobile devices, which will be released soon, I noticed that the SMS_DeviceAction class is used to invoke and query the Lock and PinReset actions. What’s even more important is the fact that the SMS_DeviceAction class isn’t documented, yet. In this blog post I’ll post the required information to successfully query the SMS_DeviceAction class and to successfully invoke the methods of the SMS_DeviceAction class.

Methods

The SMS_DeviceAction class contains the method InvokeAction. The InvokeAction method requires the following input parameters.

Parameter Data Type Description
Action String This parameter is required and should contain the name of the Action. That name can be either Lock or PinReset.
ResourceID Unit32 This parameter is required and should contain the Resource ID of the mobile device.
ResourceType Unit32 This parameter is required and should contain the Resource Type of the mobile device. The Resource Type of a mobile device is 5.

Properties

The SMS_DeviceAction class contains the following properties.

Property Data Type Description
Action String This property contains the name of the Action. That name is either Lock or PinReset.
LastUpdateTime String This property contains the time of the latest status change and is stored in the WMI time format.
ResourceID Unit32 This property contains the Resource ID of the mobile device.
ResourceText String This property contains the Response Text of the PinReset action.
SMSID String This property contains the ID of the mobile device.
SourceType Unit32 This property contains the Source Type of the mobile device.
State Unit32 This property contains the state of the action. The state will be 1 for completed and 4 for pending.

Examples

Now lets go through a couple of examples to show the usage of the SMS_DeviceAction class. This first example shows a simple query to get the information of a specific mobile device and the Lock action.

Get-WmiObject -ComputerName $SiteServer ` -NameSpace root/SMS/site_$($SiteCode) -Class SMS_DeviceAction ` -Filter "Action='Lock' and ResourceID='$MobileDeviceId'"

This second example shows an invoke of the Lock action, on a specific mobile device, via the InvokeAction method.

Invoke-WmiMethod -ComputerName $SiteServer ` -Namespace root/SMS/site_$($SiteCode) -Class SMS_DeviceAction ` -Name InvokeAction -ArgumentList ("Lock",$MobileDeviceId,5)

3 thoughts on “Invoke remote device actions via PowerShell

Leave a Comment