Skip to content

Commit

Permalink
Merge pull request #14 from MrTechGadget/AddressPSScriptAnalyzerErrors
Browse files Browse the repository at this point in the history
Fix PSScriptAnalyzerErrors due to ambiguous var
  • Loading branch information
MrTechGadget committed Oct 14, 2020
2 parents ca5186c + 4d791d6 commit d34eeb8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions PSairwatch.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
.OUTPUTS
None
.NOTES
Version: 2.4.0
Version: 2.6.1
Author: Joshua Clark @MrTechGadget
Source: https://github.com/MrTechGadget/aw-bulkdevices-script
Creation Date: 05/22/2018
Update Date: 01/14/2020
Update Date: 10/14/2020
.EXAMPLE
$ScriptPath = Split-Path $MyInvocation.MyCommand.Path -Parent
Expand Down Expand Up @@ -575,31 +575,31 @@ Function Set-LastSeenDate {
}

Function Update-Devices {
Param([array]$devices, $profile)
Param([array]$devices, $ProfileSelected)
$body = ""
$quoteCharacter = [char]34
foreach ($deviceid in $devices) {
try {
$endpointURL = "https://${airwatchServer}/api/mdm/devices/profiles?searchBy=Serialnumber&id=${deviceid}"
$webReturn = Invoke-RestMethod -Method Get -Uri $endpointURL -Headers $headers
if ($webReturn) {
$r = $webReturn.DeviceProfiles | Where-Object { $_.Id.Value -eq $profile}
$r = $webReturn.DeviceProfiles | Where-Object { $_.Id.Value -eq $ProfileSelected}
if ($r.Status -eq 1) {
$devid = $webReturn.DeviceId.Id.Value
$endpointURL2 = "https://${airwatchServer}/api/mdm/profiles/$profile/install"
$endpointURL2 = "https://${airwatchServer}/api/mdm/profiles/$ProfileSelected/install"
$body = "{ " + $quoteCharacter + "SerialNumber" + $quoteCharacter + " : " + $quoteCharacter + $deviceid + $quoteCharacter +" }"
$webReturn2 = Invoke-RestMethod -Method Post -Uri $endpointURL2 -Headers $headers -Body $body
Write-Host $devid " install queued " + $webReturn2
} elseif ($r.Status -eq 0) {
$devid = $webReturn.DeviceId.Id.Value
$endpointURL2 = "https://${airwatchServer}/api/mdm/profiles/$profile/install"
$endpointURL2 = "https://${airwatchServer}/api/mdm/profiles/$ProfileSelected/install"
$body = "{ " + $quoteCharacter + "SerialNumber" + $quoteCharacter + " : " + $quoteCharacter + $deviceid + $quoteCharacter +" }"
$webReturn2 = Invoke-RestMethod -Method Post -Uri $endpointURL2 -Headers $headers -Body $body
Write-Host $devid " install queued " + $webReturn2
} elseif ($r.Status -eq 3) {
Write-Host $webReturn.DeviceId.Id.Value profile already installed.
} elseif ($r.Status -eq 6) {
$endpointURL2 = "https://${airwatchServer}/api/mdm/profiles/$profile/install"
$endpointURL2 = "https://${airwatchServer}/api/mdm/profiles/$ProfileSelected/install"
$body = "{ " + $quoteCharacter + "SerialNumber" + $quoteCharacter + " : " + $quoteCharacter + $deviceid + $quoteCharacter +" }"
$webReturn2 = Invoke-RestMethod -Method Post -Uri $endpointURL2 -Headers $headers -Body $body
Write-Host $devid " Previous Error, install queued " + $webReturn2
Expand Down

0 comments on commit d34eeb8

Please sign in to comment.