-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddSccmApplication.ps1
More file actions
37 lines (26 loc) · 858 Bytes
/
addSccmApplication.ps1
File metadata and controls
37 lines (26 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
param (
[Parameter(Mandatory = $true)]
[string] $DeviceName,
[Parameter(Mandatory = $true)]
[string] $Application)
$arrays = $Application.split(",")
import-module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' | Out-Null
cd C00:
Function Get-SCCMDeviceResourceID {
Try{
Get-WmiObject -Namespace "Root\SMS\Site_$('C00')" -Class 'SMS_R_SYSTEM' -Filter "Name='$DeviceName'" -ComputerName 'srv003679.mud.internal.co.za'
}
Catch{
$_.Exception.Message
}
}
$Resource = (Get-SCCMDeviceResourceID -DeviceName $DeviceName).ResourceID
foreach ($array in $arrays) {
Try {
Add-CMDeviceCollectionDirectMembershipRule -CollectionName $array -ResourceId $Resource
write-host $array ': ' " Success - Software has been pushed"
}
CAtch {
$array + ' - ' + $_.Exception.Message
}
}