Wednesday, March 6, 2019

Determine IP address from MAC address, in Linux

Found a switch in a closet.. not documented and I'm too lazy to haul a laptop over and try to hit the console so I took a picture of the MAC label and stumbled across this literal GEM of a one-liner:

nmap -sP <subnet>/24 >/dev/null && arp -an | grep xx:xx:xx:xx:xx:xx | awk '{print $2}' | sed 's/[()]//g'

 It literally just works.

Monday, March 4, 2019

Powershell: Scripting, copying one users group membership to another

At $work I've been working on a new On-Boarding script, and to make things easy part of this script prompts to enter an existing users SamAccountName to copy the memberof to the new user.

It took me an hour or more of solid Google-Fu but here's the result and it works perfectly:

Get-auser -identity $copyuser -properties memberof | select-object memberof -ExpandProperty memberof | add-adgroupmember -members $newuser

Cheers.