Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Complicated AD looking and naming PC

$
0
0

We are building windows 7 workstations using a custom HTA.  In this HTA we prompt for the following.

 

User Name:  Will be their full name like 'Susan Cartwright'

Office:   Will be a city name like 'Miami'

Computer Name:  

 

 

For Computer Name it will follow these standards. 

 

The first 3 letters of their city based on existing OU's in active directory

Then a single letter, either D or L to denote Desktop or Laptop

Then the first letter of the users name

Then the next 7 letters of the users name

Then a number to indicate the rev.  So if I rebuild your machine it would go from 1 to 2.

 

Example:  

 

User Name:  Susan Cartwright

Office:   Miami

 

 

In the PowerShell script there would be a list of city/OU.  Miami=MIA, Chicago=CHI etc.....

 

So the computer name would be:   MIALSCARTWRI1   if this is is a new hire who got a Laptop.  If they get a new machine or of the machine was re imaged then the name would be MIALSCARTWRI2 and so on.  

 

So the script would need to READ the UO for the computer name and if found add the next logical number.

 

I know how to explain this but how the &$^% do you write this in PowerShell ??!?   We have an .EXE that does this now but the guy who wrote it left the company and he took his source code with him.  So we only have the .EXE and that won't do so I was asked to write a new one, that is why I'm on this forum.

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles