Computer name ,user name for CITY

by gaetanm at 2013-04-07 23:06:21

Its been a whole 2 weeks since i picked up Powershell. I have been trying to understand the structure and format of it.
I have searched multiple forums but in my mind I just don’t seem to be able to put the pieces together yet.

What I’m trying to do is the following:

Get the computer name, last login user, Ip address for city name x,y,x etc then output to a csv file

Any help would greatly be appreciated

Thank you
by mjolinor at 2013-04-08 05:41:51
What have you tried so far, and what are the results?
by coderaven at 2013-04-08 08:28:06
Can you share what you have so far? Sometimes it is hard for us to determine exactly what you are wanting. Maybe just some sample output and how are you determining the City? Getting the last logged on user can be a little hard, there is a good example here. Getting the computer name and IP should be easy, because you will be providing the computer name?
by ArtB0514 at 2013-04-08 09:31:29
We’ve had to find a way report on the city and country for AD computers. Luckily, that information had been listed in the Location property for all the AD Subnets. We decided to update the AD Location and C attributes with the information so we wouldn’t have to continuously try to figure it out.

Step 1 was to examine all the subnets and create a hash table with the first 3 octects of the subnet (expanding subnets with fewer then 24 bits) as the key and another hash table with the city and country in the value field. Since the subnets are pretty stable, we saved this hash table in XML so we can reuse it as needed.

Step 2 was to go through AD and collect all the computers (using the Microsoft AD cmdlets, this will also return the IP Address). Using the first 3 octets of the IP Address, we matched against the hash table and updated the Location and C properties.

Now, all we have to do is read AD for all the information (except the last logged on user) we need for the reports.