DNS Bulk host Import

Last week I was with a customer that had multiple clients not added to the DNS server. Because we added these hosts to the new SCOM 2012 R2 environment we had only the IP address to work with. This is not user friendly and the host name of the device gives us insight of the location of the device.

So I needed a quick way to add around 250 devices directly to the DNS server.. I already had a sheet in a CMDB with the HostNames and IP adresses..

I exported these hosts and IP adresses in to a CVS file format,

now save your file as a CSV file in the format as above.
the following PowerShell Script I used to add these hosts to my DNS server..

Run the Script with DNS add premissions and al the host names will be added to your preferd zone.


Inventory your Network and Clients

Many organizations have a wide range of computers and users, for us system administrators it is difficult to get an overview. Yes, SCCM provides a list of all users who logged on previously, but can we rely on these log files? My manager asked me to retrieve a complete list of all computers and users and SCCM was the first option. The list SCCM provided was incomplete and 60% of all entries didnít have a NetworkLoginProfile or outdated user profile. 60% of 1000+ computers is muchÖ

Well how to tackle this issue:

The PowerShell command below retrieves every ip-address per user, mac-address, the user account and there computer and creates a .csv file of the result.

  1. Open PowerShell on the DC.

  2. Paste the following code in the command prompt:


import-module activedirectory
Get-ADComputer -Filter ëName -like ì*îë | Select-Object Name | epcsv Allcomputers.txt
gc Allcomputers.txt | % {$_ -replace ëîë , ìî} | Set-Content computers.txt
gc computers.txt | ? {test-connection $_ -quiet -Count 1 -ea 0} | % {
$Networks = gwmi Win32_NetworkAdapterConfiguration -ComputerName $_ | ? {$_.IPEnabled}
gwmi Win32_NetworkLoginProfile -ComputerName $_ | Sort -Descending LastLogon |
Select | ? {$_.LastLogon -like ì20120317*î} | % {
Foreach ($Network in $Networks) {
$IPAddress = $Network.IpAddress[0]
$MACAddress = $Network.MACAddress
New-Object PSObject -Property @{
ComputerName = $_.__Server
UserName = $_.Name
LastLogon = $LastLogon
IpAddress = $IPAddress
MACAddress = $MACAddress
} | Select IpAddress,MACAddress,UserName,ComputerName | ConvertTo-Csv | Select -Last 1 | ac CompleteList.csv


* Donít retrieve every pc: Domain Controllers and other servers are included as well if you filter with * only. Use the computer naming convention of your company for example: -like ìNLABC-*î to retrieve the client computers only.


This PowerShell command gives you approximately 90% results, run the script a couple of times and compare the list with each other. Of course there is 10% that will never be retrieved, (hardware damage and network related issues etc.).