Get List of Opened Applications in Windows with PowerShell

Chirag Nagrekar
Updated on 20-Nov-2020 08:49:49

4K+ Views

We can get the list of opened applications in Windows using PowerShell using Get-Process command. Get-Process command shows the currently running processes in the foreground and the background as well.If we simply run the Get-Process command then it will give the process names and their associated process IDs and CPU, memory usage.PS C:\> Get-ProcessIf we check the members of the Get-Process, there is a MainWindowsTitle Property. This property indicates the Title of the opened application.In the below example, we will find the Application Name, associated process, and the ID of the application. For example, Get-Process | Select MainWindowTitle, ProcessName, Id ... Read More

Delete Organizational Unit (OU) from Active Directory Using PowerShell

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

1K+ 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 "OU=LabUsers, DC=Labdomain, DC=Lo ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (OU=LabUsers, DC=Labdomain, DC=Local:ADOrganizationalUnit) [Remove-ADOrgan izationalUnit], UnauthorizedAccessException + FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.UnauthorizedAccessException, Microsoft.ActiveDirectory.Managem ent.Commands.RemoveADOrganizationalUnitSo for that, first you need to disable the protected mode using the Set-ADOrganizationalUnit command and then need to run the remove command as shown below.$ou = "OU=LabUsers, DC=Labdomain, ... Read More

Delete All Users from Specific OU Using PowerShell

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 OU and then we can use the Remove-ADUser command to delete them all.ExampleGet-ADUser -SearchBase "OU=LabUsers, DC=labdomain, DC=local" -Filter * | Remove-ADUser -Confirm:$false -Verbose-Confirm switch has been added to bypass the confirmation for all the users. The default confirmation is true.OutputVERBOSE: Performing the operation "Remove" on target "CN=JensonA, OU=LabUsers, DC=labdomain, DC=local". ... Read More

Rename Drive Letter in Windows Using PowerShell

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

351 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 Get-Partition command and Pipeline the Set-Partition command. For example, Get-Partition -DriveLetter 'E' | Set-Partition -NewDriveLetter 'F'If you want to rename the drive on the remote computer, then you need to take the CIMSession of the system and run the command. For example, $sess = New-CimSession -ComputerName 'Test1-Win2k12' Set-Partition -CimSession $sess ... Read More

Create Bulk Users in Active Directory Using PowerShell

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

2K+ 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 Password " -AsSecureString 1..50 | foreach{ New-ADUser -Name "TempUser$_" -AccountPassword $pass -Path "OU=LabUsers, DC=labdomain, DC=local" -ChangePasswordAtLogon $true -Enabled $true -PasThru}The above command will create 50 Temp users in the OU named LABUSERS and one time we need to enter the password while running the script and when users log in ... Read More

Connect Spring Boot to Localhost MySQL

AmitDiwan
Updated on 20-Nov-2020 07:33:57

2K+ Views

For this, use application.properties −spring.datasource.username=yourMySQLUserName spring.datasource.password=yourMySQLPassword spring.datasource.url=jdbc:mysql://localhost:3306/yoruDatabaseName spring.datasource.driver-class-name=com.mysql.cj.jdbc.DriverTo understand the above syntax, let us create a table −mysql> create table demo71 −> ( −> id int, −> name varchar(20) −> ); Query OK, 0 rows affected (3.81 sec)Insert some records into the table with the help of insert command −mysql> insert into demo71 values(100, 'John'); Query OK, 1 row affected (0.13 sec) mysql> insert into demo71 values(101, 'David'); Query OK, 1 row affected (0.49 sec) mysql> insert into demo71 values(102, 'Bob'); Query OK, 1 row affected (0.15 sec)Display records from the table using select statement −mysql> select *from ... Read More

Difference Between AND & OR Operators in MySQL

AmitDiwan
Updated on 20-Nov-2020 07:31:21

2K+ Views

The difference between AND, OR is that AND evaluates both conditions must be true for the overall condition to be true. The OR evaluates one condition must be true for the overall condition to be true.Let us create a table −mysql> create table demo70 −> ( −> id int not null auto_increment primary key, −> name varchar(20), −> age int −> ); Query OK, 0 rows affected (0.67 sec)Insert some records into the table with the help of insert command −mysql> insert into demo70(name, age) values('John', 23); Query OK, 1 row affected (0.18 sec) mysql> insert into demo70(name, age) ... Read More

Update All VARCHAR Column Rows to Display Values Before Slash in MySQL

AmitDiwan
Updated on 20-Nov-2020 07:29:12

229 Views

For this, use UPDATE command along with SUBSTRING_INDEX(). Let us first create a table −mysql> create table demo69 −> ( −> name varchar(40) −> ); Query OK, 0 rows affected (5.04 sec)Insert some records into the table with the help of insert command −mysql> insert into demo69 values('John/Smith'); Query OK, 1 row affected (0.83 sec) mysql> insert into demo69 values('David/Miller'); Query OK, 1 row affected (0.23 sec) mysql> insert into demo69 values('Chris/Brown'); Query OK, 1 row affected (0.40 sec) mysql> insert into demo69 values('Carol/Taylor'); Query OK, 1 row affected (0.36 sec)Display records from the table using select ... Read More

Combine Few Row Records in MySQL

AmitDiwan
Updated on 20-Nov-2020 07:28:10

123 Views

For this, use CASE WHEN concept. Let us first create a table −mysql> create table demo68 −> ( −> id int not null auto_increment primary key, −> company_name varchar(50), −> employee_name varchar(50), −> country_name varchar(50) −> ); Query OK, 0 rows affected (1.86 sec)Insert some records into the table with the help of insert command −mysql> insert into demo68(company_name, employee_name, country_name) values('Google', 'John', 'US'); Query OK, 1 row affected (0.29 sec) mysql> insert into demo68(company_name, employee_name, country_name) values('Google', 'Bob', 'UK'); Query OK, 1 row affected (0.10 sec) mysql> insert into demo68(company_name, employee_name, country_name) values('Google', 'David', 'AUS'); Query OK, ... Read More

MySQL LIMIT in a Range: Fail to Display First 3 Rows

AmitDiwan
Updated on 20-Nov-2020 07:25:50

128 Views

Following is the syntax to display only the first 3 rows with LIMIT set in a range −select *from yourTableName limit yourStartIndex, yourEndIndex;Let us first create a table −mysql> create table demo67 −> ( −> id int, −> user_name varchar(40), −> user_country_name varchar(20) −> ); Query OK, 0 rows affected (0.72 sec)Insert some records into the table with the help of insert command −mysql> insert into demo67 values(10, 'John', 'US'); Query OK, 1 row affected (0.19 sec) mysql> insert into demo67 values(1001, 'David', 'AUS'); Query OK, 1 row affected (0.14 sec) mysql> insert into demo67 values(101, 'Mike', 'UK'); ... Read More

Advertisements