-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCCM - Excluded MAC Addresses OSD.ps1
51 lines (41 loc) · 2.06 KB
/
SCCM - Excluded MAC Addresses OSD.ps1
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<#
.NOTES
===========================================================================
Created on: 2022-04-27
Created by: Brian Thorp
===========================================================================
.Description
Extended code to help add a mac address to be ignored by sccm for OSD. This is great for USB Dongle imaging. Contains code from
https://www.prajwaldesai.com/manage-sccm-duplicate-hardware-identifiers/
#>
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
Import-Module ActiveDirectory
$Domain = "Contoso"
# ---------------------------------------------------------------------
# Import SCCM Site
# ---------------------------------------------------------------------
# Site configuration
$SiteCode = "CM1" # Site code
$ProviderMachineName = "sccm.contoso.com" # SMS Provider machine name
# Customizations
$initParams = @{}
# Do not change anything below this line
# Import the ConfigurationManager.psd1 module
if((Get-Module ConfigurationManager) -eq $null) {
Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams
}
# Connect to the site's drive if it is not already present
if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) {
New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams
}
# Set the current location to be the site code.
Set-Location "$($SiteCode):\" @initParams
# ---------------------------------------------------------------------
$USBMac = "A0:CE:C8:14:B2:79"
$SCCMFQDN = "sccm.contoso.com"
# (Get-WMIObject -computerName “$SCCMFQDN” -Namespace root\sms\Site_CM1 -Class SMS_CommonMacAddresses).MACAddress
$MAC = Get-WMIObject -computerName “$SCCMFQDN” -Namespace root\sms\Site_CM1 -Class SMS_CommonMacAddresses
$Mac.macaddress -match $USBMac
# ---------------------------------------------------------------------
Set-WMIInstance -computerName "$SCCMFQDN" -Namespace root\sms\Site_CM1 -Class SMS_CommonMacAddresses -Argument @{MACAddress=$USBMac}