Author: Arpit Mandliya
- 26 November
Check If File Contains String in Bash
1. Overview Searching for strings in text files is a common task in bash, used in scenarios like log file analysis and configuration file searches. This article explores various methods to check if file contains String, including both case-sensitive and case-insensitive approaches. 2. Introduction to Problem Statement Let’s consider a log file named server.log: [crayon-6726232329bbd861977672/] […]
- 20 August
Get Password Policy for User in Active Directory in PowerShell
Using Get-ADDefaultDomainPasswordPolicy Cmdlet The Get-ADDefaultDomainPasswordPolicy is used to get the default password policy for the specified domain. We can use it differently in different use cases; let’s learn a few of them below. Use the Get-ADDefaultDomainPasswordPolicy cmdlet with the -Current parameter to get the default password policy for the currently logged-on user in an active […]
- 20 August
Get Proxy Settings in PowerShell
1. Introduction In environments where internet access is controlled through a proxy, PowerShell scripts often need to be aware of these settings to function correctly. This article will guide you through different methods to get proxy settings using PowerShell, focusing on the proxy address, port, and its operational status. 2. Using Net.WebProxy Class The Net.WebProxy […]
- 20 August
Get Memory Usage Percentage in PowerShell
We can have multiple use cases for getting memory usage percentages. For example: Getting overall memory usage percentage Getting overall memory usage percentage history Getting memory usage percentage for one/all processes Let’s learn them one by one. Overcall Memory Usage Percentage We can use Get-Counter and Get-WmiObject cmdlets to retrieve the overall memory usage percentage. […]
- 20 August
Get Fully Qualified Domain Name in PowerShell
Using Environment Variable Use an environment variable to get a fully qualified domain name. [crayon-672623232c22b460409544/] [crayon-672623232c231277364512/] First, we assigned the value of the environment variable ($evn:COMPUTERNAME) to the $computer_name variable. The environment variable COMPUTERNAME stored the current computer’s name or you can say the current host’s name; both meaning the same. Then, we assigned the […]
- 20 August
Loop Through JSON File in PowerShell
Using ConvertFrom-Json Cmdlet We can use the ConvertFrom-Json cmdlet to traverse the JSON file with first and nested-level keys; Let’s explore them below. Traverse JSON File Containing First-Level Keys Use ConvertFrom-Json with the foreach loop to traverse the JSON file having first-level keys only. [crayon-672623232c667421237405/] [crayon-672623232c66e780449611/] [crayon-672623232c670026631878/] We used the Get-Content cmdlet to read the […]
- 20 August
Get History of Commands in PowerShell
Using Get-History Cmdlet Using Get-History to get the complete history of the executed commands in PowerShell. [crayon-672623232c97a521616589/] [crayon-672623232c97e751697131/] In this example, the history of the commands is obtained using the Get-History cmdlet. On execution of the above code, we can see the list of executed commands is returned and displayed on the screen with their […]
- 20 August
Check If Output Contains String in Bash
1. Overview In this article, we will see how to check if output contains String in Bash using grep, Conditional Expressions, awk, sed commands with various options. 2. Introduction to Problem Statement We will use ls -l to list directories and files in long format and search for .txt string in the output. For example: […]
- 16 August
Get Mapped Drives for All Users in PowerShell
Using net use Command Use the net use command to get mapped drives for all users in PowerShell. [crayon-672623232e37f076164951/] [crayon-672623232e384727367708/] In the above example, we used the net use command to list all the mapped drives for all users on the local machine. Both drive letters (K: and Z:) were mapped to the same user. […]