Category: Commands

ComputerCarriage > Posts > Commands

Howto use journalctl command usage RHEL 7 / 8

syslogs which gets messages sent in systemd-journald and stored the data in the disk. To view the systemd messages execute journalctl and can be used with additional parameters. In this post we are going to see quick howto use journalctl command and how to use it

Simple IP calculator Subnet using korn shell script v1.0

In this post we are going to see how to write a script to find the subnet calculator, we are using korn shell to write. the interpreter we are going to use /bin/ksh, the korn shell supports MacOS, Linux and Unix flavours. This will be helpful for assign the ip address to the server ip planning.

Git version control (latest 2.28.0) how to

In general the version control is used to preserve the changes made in a software codes, documents and other formats. For example if a group people are accessing the documents like release notes or instructions, if someone edits, so that we can find what he has changed from the previous versions, so that we can able to restore the changes made and back to original. we have the history of documents that are stored in version controlled.

dnf Package manager utility RHEL / CentOS 8 / Fedora

dnf or Dandified YUM utility used in since Fedora 18, RHEL / CentOS8, In this blog we are going to see dnf features and how to use. dnf package manager utility is used to install / remove / update package and dependencies, the dnf repolist command will display the available repos in the dnf repository

On-Demand sar command usage (Ubuntu 18.04)

sar informations are recorded for each and every second, we can see the current sar data’s as well as historic datas from the sar file, two files are written in the default path of sar configuration. i.e., saXX and sarXX

Use sar -f will get the historic data , example sar -f /var/log/sa/sa10 -r, will show the memory usage for the month day10.

Quick Health check on Linux servers v1.0

When users are reporting the servers are slow or facing issues in the connection, few commands that will make quick understanding about the system, The first and for most is doing the connectivity check from the local machine(laptop or desktop), ping server name, If we are successfully able to get the ping results, Connect to the server and do the basic commands

Easy listing block devices using lsblk

lsblk command list all available device or a block devices. Also read the sysfs filesystem and udev db togather information.
Expect RAM disks prints in tree format. lsblk –help will show list of options that can be used.

by default the NAME,MAJ:MIN,RM,SIZE,RO,TYPE,MOUNTPOINT columns will be listed. we can also customize the menus. The lsblk command will be very helpful while we adding / removing the disk, to check mounted filesystem of the disks.

AD Powershell Scripts – for New Active Directory user creation

AD Powershell Scripts – for New Active Directory user creation

Hello All

We all know that there are many ways to create user accounts in Active directory like below :

  • Creating new users with Active Directory Administrative Center
  • Creating new with Active Directory Users and Computer
  • Creating new users with the dsadd command
  • Creating new users user powershell scripts (PS1)

But as a admin you all know powershell script will makes your work easy with less effort and zero error.

To help you in this part we have shared very simple powershell script below which helps you to creates a new active directory(AD) user account in single or bulk. 

and of course, there are plenty of scripts already available in internet but what I noticed and which makes me to write this post is most of the freely available scripts are just downloadable – that’s it, no reference or explanation which is quite hard for the system admin who has null/less experience with scripting to get modified based on their requirement. 

Here in this post I tried to give detailed insight in a simple way about the script for system admins who have less/null experience with scripting so that they can use it directly or alter this flexible script as per their requirement. 

Let’s jump.

Very first thing, to run this script you need active directory powershell module and privilege to create AD user object in your AD domain.

Admin has to type and save the new users details in the newusers.csv before running the script.

Below is the script on the on bold # statement I have given the explanation for the code for your better understanding. Please revert incase of any feedback or query.

AD Powershell Scripts

#Enter a path to your import CSV file
Import-Module ActiveDirectory
$ADUsers = Import-csv C:\scripts\newuser\newusers.csv # This is the file where we will input new users details

foreach ($User in $ADUsers) #For loop capture the details of new users feeded in the above CSV file and stores it in the respective variable
$OU = "<OU Path>" #Specify DN of the OU where you wish to create account
$Username = $User.username
$Password = $User.password
$FullName = $User.FullName
$Firstname = $User.firstname
$Lastname = $User.lastname
$DisplayName = $User.DisplayName
$Title = $user.Title
$Department = $User.department
$Manager = $User.Manager # provide manager's AD Samaccount Name in the csv file
$OfficePhone = $User.OfficePhone
$MobilePhone = $User.MobilePhone
$Company = "<Organization's Name>" # Specify organization name
$Country = "<Country Code>" # Specify county code e.g., US for USA, DE for Germany
$GroupName1 = "<Group Name>" # Specify Group name if you want to add user in the any of the group
$GroupName2 = "<Group Name>" # Specify Group name if you want to add user in the any of the group

#Check if the user account already exists in AD
if (Get-ADUser -F {SamAccountName -eq $Username})
#If user does exist, output a warning message
Write-Warning "A user account $Username has already exist in Active Directory."
#If a user does not exist then create a new user account

#Account will be created in the OU listed in the $OU variable in the CSV file; don’t forget to change the domain name in the"-UserPrincipalName" variable
New-ADUser `
-SamAccountName $Username `
-UserPrincipalName "$" `
-Name $FullName `
-GivenName $Firstname `
-Surname $Lastname `
-DisplayName $DisplayName `
-Title $Title `
-Department $Department `
-Manager $Manager `
-OfficePhone $OfficePhone `
-MobilePhone $MobilePhone `
-Company $Company `
-City "Doha" `
-Country $Country `
-Enabled $True `
-ChangePasswordAtLogon $True `
-Path $OU `
-emailaddress "$" `
-AccountPassword (convertto-securestring $Password -AsPlainText -Force) 

write-host $userName 'has been created' -foregroundcolor DarkGreen

#Adding newly created user to the security groups (if any)

Add-ADGroupMember -Identity $GroupName1 -Members $userName
write-host 'Account' $userName 'added' on $GroupName1 -foregroundcolor DarkGreen
Add-ADGroupMember -Identity $GroupName2 -Members $userName
write-host 'Account' $userName 'added' on $GroupName2 -foregroundcolor DarkGreen


And this is how  the CSV file will look like.

You can download the script & csv file template in the below Github link


Refer below link to learn more AD powershell module cmdlets


AD Powershell Scripts