Archy.net

Subscribe to Archy.net feed
Don't Follow the Trend
Updated: 3 hours 41 min ago

DHCP – Activate Filter “Allow” & import MAC address from SCCM by WMI request

Tue, 08/29/2017 - 12:08

Hello folks,
Recently, i have post a script to interroge SCCM and find the MAC address informations. In this post, i show you how activate DHCP Filter “Allow” to protect your DHCP delivery lease to deny access to your network (i know, there is NAP or NAC but, it is a simple way to block the issuance of a DHCP lease).

Prerequirements

First, you need to create a Active Directory user and give to this account rights “DHCP Administrator”.

In SCCM console, add this users to group “Read-only Analyst” .

Activate filter “Allow” on DHCP server

Connect to your DHCP Server and open the management consoleOn the IPV4 tab, open the drop-down menu, and then select the “Filters” option and right-click the “Allow” folder and select “Enable”.

From now, the DHCP server no longer delivers leases.

On the DHCP Server, launch this script for retreive and add the MAC Address informations from SCCM Server to filter list “Allow”.

Source code   # Connection information $SiteName = "FR1" $ServerSite = "sccm" # WMI Request $ImportSCCM = $(Get-WmiObject -Class SMS_R_SYSTEM -Namespace "root\sms\site_$SiteName" -computerName $ServerSite) # Create collection $Mycoll = @() foreach ($obj in $ImportSCCM) { Write-Host $obj.NetbiosName $obj.MACAddresses $obj.OperatingSystemNameandVersion $Mydetails = "" | Select-Object PCName, MacAddress, OS If ($([String]$obj.MACAddresses) -eq "") { $Mydetails.PCName = $obj.NetbiosName $Mydetails.MacAddress = "Nul" $Mydetails.OS = $obj.OperatingSystemNameandVersion } Else { $Mydetails.PCName = $obj.NetbiosName $Mydetails.MacAddress = [String]$obj.MACAddresses -replace ":","-" $Mydetails.OS = $obj.OperatingSystemNameandVersion } $Mycoll += $Mydetails } #Add MacAddress into DHCP Filter foreach ($objects in $Mycoll) { Add-DhcpServerv4Filter -List Allow -MacAddress $objects.MacAddress -Description $objects.PCName -Confirm:$false -Force -Verbose } # Remove Obsolete entries Compare-Object $(($Mycoll | Select-Object MacAddress).MacAddress) $(Get-DhcpServerv4Filter -ComputerName $DHCPServer -List Allow | Select-Object MacAddress).MacAddress -IncludeEqual | % { if ($_.SideIndicator -eq "=>") { Remove-DhcpServerv4Filter -ComputerName $DHCPServer -MacAddress $_.InputObject -Confirm:$false -Verbose } }

When the script is finished, you can see into the management console of DHCP Server, the entries are add into the “Allow” list.

The DHCP server correctly delivers the lease of the device whose MAC Address is allowed.

 

Categories: Community, Virtualisation

SCCM – Find Devices MAC Address

Fri, 08/25/2017 - 12:56

Hello Folks,

This week I needed to export from SCCM, the devices name and MAC Address to a CSV file.

I need this file to create green list into DHCP server. The Green list give permission to have a lease from DHCP server. I will speak of this subject in a futur post.

To find informations on devices into SCCM, we can work with WMI Class of SCCM. This script is based on WMI request.

Source code   $SiteName = "FR1" $ServerSite = "sccm" $Mycoll = @() foreach ($obj in (Get-WmiObject -Class SMS_R_SYSTEM -Namespace "root\sms\site_$SiteName" -computerName $ServerSite)) { Write-Host $obj.NetbiosName $obj.MACAddresses $obj.OperatingSystemNameandVersion $Mydetails = "" | Select-Object PCName, MacAddress, OS If ($([String]$obj.MACAddresses) -eq "") { $Mydetails.PCName = $obj.NetbiosName $Mydetails.MacAddress = "Nul" $Mydetails.OS = $obj.OperatingSystemNameandVersion } Else { $Mydetails.PCName = $obj.NetbiosName $Mydetails.MacAddress = [String]$obj.MACAddresses $Mydetails.OS = $obj.OperatingSystemNameandVersion } $Mycoll += $Mydetails } $Mycoll | Out-GridView

 

 

Categories: Community, Virtualisation