Chirag Nagrekar has Published 465 Articles

How to delete the Organizational Unit (OU) from the active directory using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 20-Nov-2020 08:48:05

867 Views

To delete the OU from the Active Directory using PowerShell, we need to use the command Remove-ADOrganizationUnitRemove-ADOrganizationalUnit -Identity "OU=LabUsers, DC=Labdomain, DC=Local"If the OU is protected from the accidental delete, you will receive an Access is Denied error as shown below.Remove-ADOrganizationalUnit : Access is denied At line:1 char:1 + Remove-ADOrganizationalUnit -Identity ... Read More

How to delete all users from specific OU using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 20-Nov-2020 08:46:25

2K+ Views

To remove all users from the specific OU, we need to first retrieve the users from that OU. For example, we have 3 users in the OU called LABDOMAIN and we need to delete them all.Get-ADUser -SearchBase "OU=LabUsers, DC=labdomain, DC=local" -Filter *The above command will retrieve users from the specific ... Read More

How to rename the drive letter in Windows using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 20-Nov-2020 08:45:13

280 Views

We can rename a drive letter of a disk using PowerShell with the Set-Partition command. An example is shown below.In the Windows OS, we have E: and we need to rename its partition to the F: You can run the below command.Set-Partition -DriveLetter 'E' -NewDriveLetter 'F'You can also run the ... Read More

How to create bulk users in the active directory using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 20-Nov-2020 08:44:25

1K+ Views

Using Random Account NameTo create bulk users in the AD using PowerShell, there are multiple methods. For example, let say if you want to create 50 sample users for the lab environment without considering the other required properties, then you can use the below command, $pass = Read-Host "Enter Account ... Read More

Where the PowerShell Modules are stored?

Chirag Nagrekar

Chirag Nagrekar

Updated on 11-Nov-2020 13:07:57

25K+ Views

PowerShell modules are stored in their module path. Module paths can be retrieved using an environmental variable $env:PSModulePath. To get a better view, we will split the variable path with a semicolon.$env:PSModulePath -split ';' C:\Users\Administrator\Documents\WindowsPowerShell\Modules C:\Program Files\WindowsPowerShell\Modules C:\Windows\system32\WindowsPowerShell\v1.0\ModulesYou can see the 3 paths above. Each path has Modules stored as per their ... Read More

How to get supported parameters of the cmdlet in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 11-Nov-2020 13:06:55

206 Views

To know which parameters are supported by cmdlets, Get-Command retrieves the properties of the command. For example, We need to find the Get-Process parameters so the Get-Command will retrieve the command information and Full List will provide you the properties.Get-Command Get-Process | flOnce you run the command, it shows the ParameterSets property and ... Read More

How to use Split-Path command in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 11-Nov-2020 13:03:52

2K+ Views

Split-Path is to retrieve the part of the specified path, such as a parent folder, a subfolder, or a file name. It can also tell if the path is relative or absolute.This command supports a few parameters which help to retrieve the part of the specified path. Consider we have ... Read More

How to get DNS IP Settings using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 11-Nov-2020 13:01:40

17K+ Views

Ipconfig /all command also retrieves the DNS settings for all the network interfaces. This command can be run on both cmd and PowerShell. For example, ExamplePS C:\Users\Administrator> ipconfig /all Windows IP Configuration    Host Name . . . . . . . . . . . . : Test1-Win2k16    Primary Dns Suffix ... Read More

How to get IP address settings using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 11-Nov-2020 12:53:38

3K+ Views

To get the IP address of the system we can use IPConfig command in cmd and the same command can be used in PowerShell. IPConfig command shows all the connected and disconnected adapters including IPv4 and IPv6. For example, ExamplePS C:\Users\Administrator> Ipconfig Windows IP Configuration Ethernet adapter Ethernet0:    Connection-specific DNS Suffix  . ... Read More

Difference between Write-Output and Write-Host command in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 11-Nov-2020 12:48:52

5K+ Views

Have we ever wondered, Write-Output and Write-Host both are used to print the strings or the output of the command then what is the difference between them?ExamplePS C:\> Write-Output "Test String" Test String PS C:\> Write-Host "Test String" Test StringThe output remains the same.The first major difference is storing the ... Read More

Advertisements