Skip to content

Commit

Permalink
Added Install-Application and Query-Device scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTechGadget committed Jun 18, 2021
1 parent f1c03bf commit c6b54bd
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
61 changes: 61 additions & 0 deletions Install-Application.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<#
.SYNOPSIS
Sends an App install command to a list of devices
.DESCRIPTION
To do: provide better feedback/more options, choose platform first to eliminate errors selecting profiles with the exact same name.
.INPUTS
AirWatchConfig.json
Serials.csv
.OUTPUTS
NO OUTPUT CURRENTLY:Outputs a CSV log of actions
.NOTES
Version: 1.0
Author: Joshua Clark @MrTechGadget
Creation Date: 4/20/2021
Site: https://github.com/MrTechGadget/aw-bulkdevices-script
.EXAMPLE
Install-Application.ps1 -file .\Devices.csv -fileColumn "device_id" -appId "12345" -appType "purchased"
#>

[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=0,ValueFromPipeline=$true,HelpMessage="Path to file listing Serial Numbers.")]
[string]$file,

[Parameter(HelpMessage="Name of Serial Number column in file, default is SerialNumber")]
[string]$fileColumn = "SerialNumber",

[Parameter(Mandatory=$True,HelpMessage="ID of Application")]
[string]$appId,

[Parameter(Mandatory=$True,HelpMessage="App Type: internal, public, or purchased")]
[string]$appType
)

Import-Module .\PSairwatch.psm1

<#
Start of Script
#>

$devicelist = Read-File $file $fileColumn
#$OrgGroups = Get-OrgGroups
#$GroupID = Select-Tag $OrgGroups
#$Platform = Select-Platform

#$ApplicationList = Get-Applications $GroupID $Platform
#$ApplicationSelected = Select-Tag $ApplicationList
$i=0
foreach ($device in $devicelist) {
$i++
#Write-Progress -Activity "Installing Application" -Status "$($i) of $($devicelist.Count)" -CurrentOperation "$($device.$fileColumn)" -PercentComplete ((($i)/(@($devicelist).Count))*100)
Write-Host "$i of $($deviceList.Count)"
$json = '{ "DeviceId": '+ $device +' }'
try {
$installresults = Install-App $json $appId $appType
}
catch {
Write-Warning "Error Installing App"
}

}
50 changes: 50 additions & 0 deletions Query-Device.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<#
.SYNOPSIS
Send Query Command to list of devices with a device ID
.DESCRIPTION
To do: provide better feedback/more options, choose platform first to eliminate errors selecting profiles with the exact same name.
.INPUTS
AirWatchConfig.json
Serials.csv
.OUTPUTS
NO OUTPUT CURRENTLY:Outputs a CSV log of actions
.NOTES
Version: 1.0
Author: Joshua Clark @MrTechGadget
Creation Date: 4/21/2021
Site: https://github.com/MrTechGadget/aw-bulkdevices-script
.EXAMPLE
Query-Device.ps1 -file .\devices.csv -fileColumn "device_id"
#>

[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=0,ValueFromPipeline=$true,HelpMessage="Path to file listing Serial Numbers.")]
[string]$file,

[Parameter(HelpMessage="Name of Device ID column in file, default is device_id")]
[string]$fileColumn = "device_id"
)

Import-Module .\PSairwatch.psm1

<#
Start of Script
#>

$devicelist = Read-File $file $fileColumn
$i=0
foreach ($device in $devicelist) {
$i++
#Write-Progress -Activity "Querying Devices" -Status "$($i) of $($devicelist.Count)" -PercentComplete ((($i)/(@($devicelist).Count))*100)
Write-Host "$i of $($deviceList.Count)"
$json = ' '
$endpoint = "mdm/devices/$device/commands?command=DeviceQuery"
try {
$queryresult = Send-Post $endpoint $json
}
catch {
Write-Host "Error sending query command"
}

}

0 comments on commit c6b54bd

Please sign in to comment.