Deepak Ingale1
Mega Sage

In continuation to previous blog post ServiceNow Orchestration and Powershell :   Setup your virtual AD serverServiceNow Orchestration and Powershell :Set-up and test network communication in a series of Orchestration and Powershell, we are now going create small organizational structure for our Organization or domain.

1) Some OU (Organizational Units) in our AD Server (Locations for our organization)

2) Some Users in these OUs. (Employees, Contractors etc.)

Open the workflow we have setup in previous post.

Type below command   as input to workflow

New-ADOrganizationalUnit -Name 'India'   -Path "DC=YourDomainControllerName,DC=COM" -Server ADServerIPAddress -credential $cred

find_real_file.png

Once done, we will create some cities under OU="India".

Run workflow with below commands to create additional OUs in your domain controller

New-ADOrganizationalUnit -Name 'Banglore'   -Path "OU=India, DC=YourDomainControllerName,DC=COM" -Server ADServerIPAddress -credential $cred

New-ADOrganizationalUnit -Name 'Pune'   -Path "OU=India, DC=YourDomainControllerName,DC=COM" -Server ADServerIPAddress -credential $cred

New-ADOrganizationalUnit -Name 'Hydrabad'   -Path "OU=India, DC=YourDomainControllerName,DC=COM" -Server ADServerIPAddress -credential $cred

New-ADOrganizationalUnit -Name 'US'   -Path "DC=YourDomainControllerName,DC=COM" -Server ADServerIPAddress -credential $cred

New-ADOrganizationalUnit -Name 'Belgium'   -Path "DC=YourDomainControllerName,DC=COM" -Server ADServerIPAddress -credential $cred

New-ADOrganizationalUnit -Name 'France'   -Path "DC=YourDomainControllerName,DC=COM" -Server ADServerIPAddress -credential $cred

New-ADOrganizationalUnit -Name 'New York'   -Path "OU=US, DC=YourDomainControllerName,DC=COM" -Server ADServerIPAddress -credential $cred

New-ADOrganizationalUnit -Name 'Brussels'   -Path "OU=Belgium, DC=YourDomainControllerName,DC=COM" -Server ADServerIPAddress -credential $cred

New-ADOrganizationalUnit -Name 'Paris'   -Path "OU=France, DC=YourDomainControllerName,DC=COM" -Server ADServerIPAddress -credential $cred

Now go to our Active Directory server and open "Active Directory Users and Computer" console.

You will notice OUs got created based on commands we run from our workflow

find_real_file.png

Now lets create some sample users under these OUs, Run these commands using ServiceNow workflow we have build.

New-ADUser -Name "Sachin" -path "OU=Banglore,OU=India,DC=YourDomainControllerName,DC=com" -Server ADServerIPAddress -credential $cred

New-ADUser -Name "Rahul" -path "OU=Banglore,OU=India,DC=YourDomainControllerName,DC=com" -Server ADServerIPAddress -credential $cred

New-ADUser -Name "Robin" -path "OU=Hydrabad,OU=India,DC=YourDomainControllerName,DC=com" -Server ADServerIPAddress -credential $cred

New-ADUser -Name "Frank" -path "OU=Paris,OU=France,DC=YourDomainControllerName,DC=com" -Server ADServerIPAddress -credential $cred

find_real_file.png

find_real_file.png

Once done, you should be able to see users got created under OUs we have specified.

So now we are ready with some OUs and Some users under it, you can add number of similar OUs and users and have your own organisational hierarchy

Kindly do not forget to like or bookmark this article if it helps you.

13 Comments