So i get the result i want, but how to i actually set this to be my computername when i deploy a VM.Like a said i got the script working and i have confirmed it via a MDT task sequence.What I need to understand is when the task sequence or WIndows PE sets the computer name so i can put my powershell script before that task.If thats a server, PS remoting will be enabled by default, otherwise youll need to enable it.
Osdcomputername Mdt As Computername How To I ActuallyOn this page, the person wrote a script to keep using existing computer names when imaging with MDT. From Google search, I understand that it is not possible for a computer to contact AD during PE. So I thought the proper way of doing this would be the following: - using a script to determine the current computer name during PE, and store it in a variable. COMP1 - Name the computer as usual, e.g. COMP2 - After imaging (towards the end of the TS), compare if COMP1 and COMP2 has the same value, (in case the re-purposed computer is already using the new naming scheme); - If yes, do nothing - If no, remove COMP1 from AD using a batch or PS script. If anyone could appoint me the right direction, or provide their way of doing it, that would be much appreciated. Luckily, we can pass variables to a script if the script is set up to do so (parameters). Youll need to use the credentials of an account that has access to delete objects from AD. Add a Run Powershell Script step somewhere in State Restore (I like to use the Custom Tasks node for this type of thing). The script you referenced is a great start to doing the rename you describe. Then it dives into the registry for that volume and pulls the above key. Get-Volume (looking for drive letters) Get-ItemProperty -Path HKLM:SYSTEMControlSet001. Youll probably want to use invoke-command to run this on a DC or a workstation with RSAT. Osdcomputername Mdt As Computername Full LDAP StringYou could alternatively use ADSI, but Im pretty sure you need the full LDAP string of the object youre trying to delete. I have a powershell script that runs every night and evaluates all computer objects in AD. If the object hasnt contacted AD in 180 days then the object is disabled and moved to a Pending Deletion OU. I manually bulk delete objects from this OU from time to time. The problem is the lastlogontimestamp is not always accurate despite checking with all DCs. I believe one of the causes is that more than half of our employees work in the field, and most of them do not have the need to ever come into a corporate office or using VPN. Another reason why I picked 180 days is we decided if the machine hadnt been authenticated in 180 days, we wanted to put eyes on it before it got back on the network. Any chance you could build the old name based off the new name I was just thinking you could run a powershell script against a list of all the new names and search for the old names pattern based on it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |