This topic contains 6 replies, has 5 voices, and was last updated by
April 14, 2019 at 6:13 pm #151580
I am very new to powershell and basically i want to run a CSV script that creates an Organizational Unit and a group within that Organizational Unit with the same name. I am not sure how to go about this, do I have to put the powershell commands into a CSV file and just Import-CSV -Path "Path" because doing this does not work.
April 14, 2019 at 6:17 pm #151589ModeratorPoints: 1,959Rank: Community Hero
Acheiveable, can you share the code you have, it will help others to understand the problem in the code better
April 14, 2019 at 7:17 pm #151605ParticipantPoints: 948Rank: Major Contributor
Well, the powershell commands would go in a .ps1 file.
April 14, 2019 at 9:25 pm #151614ParticipantPoints: 1,315Rank: Community Hero
You have to show your work for us to try and help.
What you are asking for help on is done every day.
It's OK to be new to anything. We all have to start somewhere. Yet, you really should spend time getting to know a tool before using it. Especially in production environments, as you could really cause major damage. There are plenty of free / no cost or low cost online videos, courses, book, etc., you can use.
Windows PowerShell Survival Guide
The purpose of this document is to help you to learn more about PowerShell and to be successful in applying it. This document seeks to point to the best content on the web to enable you to reach that goal.
Read the built-in help files fully
# Get parameters, examples, full and Online help for a cmdlet or function (Get-Command -Name Get-Content).Parameters Get-help -Name Get-Content -Examples Get-help -Name Get-Content -Full Get-help -Name Get-Content -Online Get-Help about_* Get-Help about_Functions
There are tools that will write the Active Directory code for you, already on Windows server.
Active Directory Administrative Center: Getting Started
Active Directory Administrative Center
Step-By-Step: Utilizing PowerShell History Viewer in Windows Server 2012 R2
Reading in a txt / csv file is an intro to PowerShell thing, and done daily by anyone using it. Again, there are tons for resources all over the web showing exactly how to do this. For example, though this is talking about creating users, creating any AD object is the same, for the most part.
Use PowerShell to Read a CSV file and Create Active Directory User Accounts
There are lots of videos on YouTube, Microsoft Virtual Academy, MS Channel9 on PowerShell holistically and some on this very topic, meaning creating AD objects using PowerShell.
There are pre-built scripts in the MS powershelgallery.com for the same.
Bulk import of organizational units from CSV
I had a project where i needed to replicate the OU structure in a dummy test domain for validation of group policy objects (things like mapped drives/printers for groups) I created this script to import the OU structure that I had pulled from our existing AD environment into my
Yet without learning PowerShell, you may not fully understand what and why something is the why it is or works he way it does.
Rule #1 is never run any code, form anyone, that you don't fully understand the outcomes / impacts of running it. Never do it in a production environment, if you have not done it in a test lab first. If you don't have a test lab, then use the MS TechNet Virtual Labs to practice.
TechNet Windows Server 2012 Virtual Lab
Reference books you should thoroughly read and reference regularly in your efforts.
Learn Windows PowerShell in a Month of Lunches 3rd Edition
Donald W. Jones (Author), Jeffrey Hicks (Author)
Windows PowerShell Cookbook: The Complete Guide to Scripting Microsoft's Command Shell 3rd Edition
Lee Holmes (Author)
Windows PowerShell in Action 3rd Edition
by Bruce Payette (Author), Richard Siddaway (Author)
MOC on-demand, if you cannot go in person.
April 15, 2019 at 3:53 am #151650
April 15, 2019 at 1:36 am #151626
April 15, 2019 at 3:49 am #151647
This is basically what I've come up with after all the tutorials and such ive been researching.
You must be logged in to reply to this topic.