Since you say you are new. It is vital you get ramped up first. There are a bunch of no-cost ways to do this. See this post / discussion.
Secondly, you can use tool that are already built for this sort of thing, like the downloads from powershellgallery.com or the MS scriptingguys blog.
You can let Windows Server write the code for you. Using the ‘ADAC - Active Directory Administrative Center’. See these articles.
Active Directory Administrative Center: Getting Started
Active Directory Administrative Center
Step-By-Step: Utilizing PowerShell History Viewer in Windows Server 2012 R2