The other day I was asked the to run a report by security team on which AD users had dial-in configured for a static IP address and what IP address was assigned, if any.

I did a quick Get-Aduser on the supplied test account and here are the results:

GivenName               : Chris
msRADIUSFramedIPAddress : 1869573999
Name                    : Chris
ObjectClass             : user

Well that’s odd  “1869573999″ does not look like an IP address to me.  A quick  MSDN for more information.  Not much there UGH.  I was able to find several scripts to converts IPv4 address to binary or decimal.  After much trial and error I was able to come up with the following:

Function ConvertRADIUSIPAddress($RADIUSIPAddress) {
$bin=::ToString($RADIUSIPAddress,2).PadLeft(32,'0').ToCharArray()
$A=::ToByte($bin[0..7] -join "",2)
$B=::ToByte($bin[8..15] -join "",2)
$C=::ToByte($bin[16..23] -join "",2)
$D=::ToByte($bin[24..31] -join "",2)
return $($A,$B,$C,$D -join ".")
}

To use the function you only need to supply the uses “msRADIUSFramedIPAddress” value.  To make it more useful added some PSObject and ran it through a for loop using GET-Aduser.

$users = get-aduser  -f * -Properties GivenName,surname,name,msRADIUSFramedIPAddress,DistinguishedName,LastLogonDate,whenCreated,whenChanged,enabled,manager |select GivenName,surname,name,msRADIUSFramedIPAddress,DistinguishedName,LastLogonDate,whenCreated,whenChanged,enabled,manager 
foreach ($un in $users){
  
   New-Object PSObject -Property @{
                Name = $un.Name
                DN = $un.DistinguishedName
                Enabled = $un.Enabled
                Manager = $un.manager
                LastLogin = $un.LastLogonDate
                Created = $un.whenCreated
                IP =  ConvertRADIUSIPAddresss $un.msRADIUSFramedIPAddress
                fullname = $un.GivenName + " " + $un.Surname
                
            }
 }

Now when I run the script it pulls back a list of users with a human readable IPV4 address.

That is it for now.

Thanks,

Chris

 

 

About the Author: steve bowman

Three Minutes For A More Secure & Efficient Infrastructure

Short and to the point, Steve’s Email Blasts give you endpoint management tips, tricks, and news in three minutes or less email read-time, guaranteed.

Model says no to spam. Privacy Policy

Model Technology Solutions

Model Technology Solutions is a small but mighty band of infrastructure experts. We’ve helped companies in diverse industries to modernize and automate their infrastructures through effectively managing their Microsoft endpoint suite.

With us on your team, you’ll watch your security and compliance go up and your IT team’s costs (and headaches) go down. You’ll relax in knowing that your endpoints will be secure and online when your users need them most. And you’ll finally get back to your most-important tasks.

Model Technology Solutions
12125 Woodcrest Executive Drive, Ste. 204 Creve Coeur, MO 63141

Phone: (314) 254-4138
General Inquiries: model@model-technology.com
Sales and Quotes: sales@model-technology.com