I’m trying something that I thought of to be simple but somehow issn’t to me.
I need to create new AD computer accounts based on the last account found in the AD.
In our company we have a strikt naming convention which should make it easy to create new accounts based on the last one.
Our naming schema is somehting like: USLAXDT123456
The last 6 digits are running numbers. So basically I only need to iterate this by 1.
My first approach would be to select -last 1 of the AD acccounts.
Split the name from the number. ($var = USLAXDT123456.remove(0,7)
Iterate the number… somehow maybe like this:
$var += 1
Then bring the string part back together with the number.
Think you’re heading on the right lines. For splitting the number from the letters, you can also use .substring, and for working out the next number, Measure-Object with the -maximum parameter is your friend.