Skip to content

Commit

Permalink
Fixing an issue in Push-EnrollUpdateableAsset
Browse files Browse the repository at this point in the history
  • Loading branch information
David Brook committed Mar 22, 2023
1 parent 6185748 commit 6be02aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Fixed a coding issue in the Push-EnrollUpdatableAsset function

## [1.0.17] - 2023-03-22
## Fixed
- Fixed an issue with the Add-DeploymentAudienceMember function where it was not processing the input correctly.
Expand Down
23 changes: 10 additions & 13 deletions source/Public/Push-EnrollUpdatableAsset.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ function Push-EnrollUpdatableAsset {
$azureDeviceIDs
)
begin {
Write-Verbose "Starting function $($MyInvocation.MyCommand.Name)"
# Create the param body base
Write-Verbose "Creating the param body base"
$paramBody = @{
updateCategory = "driver"
assets = @(
Expand All @@ -29,25 +31,19 @@ function Push-EnrollUpdatableAsset {
}
process {
if($PSCmdlet.ShouldProcess("Enroll Assets", "Enroll Assets")) {
$updateAudienceMembers = Get-DeploymentAudienceMember -policyID $updateAudienceID
Write-Verbose "Getting updatable assets"
$updatableAssets = Get-UpdatableAsset
Write-Verbose "Checking if the assets are already enrolled"
foreach ($id in $azureDeviceIDs) {
IF (-Not($updateAudienceMembers.id -contains $id)) {
IF (-Not($updatableAssets | Where-Object { $_.id -match $id }).enrollments.updateCategory -notcontains "driver") {
Write-Verbose "Adding $id to the param body, as it is not already enrolled"
$memberObject = @{
"@odata.type" = "#microsoft.graph.windowsUpdates.azureADDevice"
id = $id
}
$paramBody.addMembers += $memberObject
$paramBody.assets += $memberObject
}
}
}
$updatableAssets = Get-UpdatableAsset
foreach ($id in $azureDeviceIDs) {
IF (-Not($updatableAssets | Where-Object { $_.id -match $id }).enrollments.updateCategory -notcontains "driver") {
$memberObject = @{
"@odata.type" = "#microsoft.graph.windowsUpdates.azureADDevice"
id = $id
}
$paramBody.assets += $memberObject
Write-Verbose "Param Body has $($paramBody.assets.Count) assets"
}
}
}
Expand All @@ -58,5 +54,6 @@ function Push-EnrollUpdatableAsset {
-Uri "https://graph.microsoft.com/beta/admin/windows/updates/updatableAssets/enrollAssets" `
-Body $paramBody
}
Write-Verbose "Finished function $($MyInvocation.MyCommand.Name)"
}
}

0 comments on commit 6be02aa

Please sign in to comment.