• 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-65f961dd3cc11219316715/] […]

  • PowerShell get password policy for user in active directory
    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 […]

  • PowerShell Get Proxy Settings
    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 […]

  • PowerShell get Memory Usage Percentage
    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. […]

  • PowerShell get fully qualified domain name
    20 August

    Get Fully Qualified Domain Name in PowerShell

    Using Environment Variable Use an environment variable to get a fully qualified domain name. [crayon-65f961dd3d5bd508350234/] [crayon-65f961dd3d5c0088046063/] 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 […]

  • PowerShell loop through JSON File
    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-65f961dd3d808964408525/] [crayon-65f961dd3d80b655985495/] [crayon-65f961dd3d80c175720188/] We used the Get-Content cmdlet to read the […]

  • PowerShell get history of Commands
    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-65f961dd3d9fa676214833/] [crayon-65f961dd3d9fd454377048/] 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 […]

  • Bash Check if Output contains String
    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: […]

  • PowerShell get mapped drive for all users
    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-65f961dd3debb991404249/] [crayon-65f961dd3dec2082898361/] 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. […]