By using the appropriate WMI calls for the data you want to return. Do a search for scriptomatic and you should find a nice little utiliity for doing the scripts you want.