i would like to make Sub rutine to look for open Smb shares on my lan

i figured it would have to involve a port scan from 137, 138 and 139 and ip scan from x.x.x.x to x.x.x.x

i have script to resolve ip
but i would not know how to make cycle from x.x.x.x. address to x.x.x.x address

i would also like to enumarate share names and paths

any ideas?