The more you get used to PowerShell the easier it will get to build complex scripts and automate your processes. I like PowerShell just because I can copy and paste my scripts from OneNote and reuse them over and over. Preparing my lab, working out the design and later on recreating that for production with PowerShell and other unattended scripts has my general preference.
On the Windows client, server and BackOffice there are thousands of commandlets today for PowerShell. The following script has helped me to automate my process to provision a virtual machine and paste the commands to join the computer to the domain, rename the host name from auto generated Windows setup name and reboot the server.
I am creating virtual machines by manually and this join process takes many clicks. I like the following script to do that job for me. If you are using Hyper-V manager then it can be pasted from the console options directly into the virtual machine.
How to join a windows server to active directory domain with PowerShell?
# Set windows credential $SetCredential = Get-Credential # Join the computer to the domain Add-Computer -DomainName networknet.nl -Credential $SetCredential # Get Computername and Rename with WMI $Computer = Get-WmiObject Win32_ComputerSystem $Computernamenew = $Computer.Rename("NETWK-WEB-01", $SetCredential .GetNetworkCredential().Password, $SetCredential .Username) #Reboot computer to apply new settings Restart-Computer
Leave a comment