• PowerShell add quotes to String
    27 May

    PowerShell Add Quotes to String

    Using Backtick Characters Use backtick characters to add double quotes to string in PowerShell. [crayon-6605857d623a0867302873/] [crayon-6605857d623b0481909649/] Backtick character is escape character in PowerShell. Here, it is used to escape double quotes in the String. Use backtick characters to add single quotes to string in PowerShell. [crayon-6605857d623b2783245884/] [crayon-6605857d623b4672180282/] Using String Concatenation Operator Use string concatenation operator […]

  • PowerShell add array to array
    27 May

    PowerShell Add Array to Array

    Using + Operator Use the + operator to add an array to another array. [crayon-6605857d67c52420568768/] [crayon-6605857d67c5d570298260/] First, we used the array operator represented by @() to declare two arrays, $array1 and $array2, containing the values 1,2,3and 4,5,6. After that + operator is used to concatenate the two arrays together into a $newArray. In PowerShell, when […]

  • PowerShell check if account is locked
    27 May

    PowerShell Check If Account Is Locked

    Check if AD account is locked To check if AD account is locked, use Get-ADUSer cmdlet and select LockedOut property using Select-Object cmdlet. Here is the code: [crayon-6605857d67f1d425133083/] [crayon-6605857d67f24633906276/] Replace DELL with the username for which you want to check if AD account is locked or not. Get-ADUSer cmdlet is used to get specific user […]

  • PowerShell compare lastwritetime of two files
    06 May

    PowerShell Compare LastWriteTime of Two Files

    Using LastWriteTime property To compare LastWriteTime of two files in PowerShell: Use Get-Item to get items. Use the if-else block to compare LastWriteTime of both files. [crayon-6605857d6ab7f750859221/] [crayon-6605857d6ab8c733035088/] Using Compare-Object Cmdlet To compare the LastWriteTime of two files in PowerShell: Use Get-Item to get items. Use the Compare-Object cmdlet to compare the LastWriteTime of two […]

  • 04 May

    Check if AD User Exists in PowerShell

    In PowerShell, we must import the ActiveDirectory module to use the Get-ADUser cmdlet. If you have imported it already, you can jump to the Checking If AD User Exists in PowerShell section; otherwise, let’s continue with us step-by-step below. Installing the ActiveDirectory Module To import the ActiveDirectory module, we first need to install it. So, […]

  • Get logged on users in PowerShell
    03 May

    Get Logged on Users in PowerShell

    This topic can be interpreted as getting all current logged-on users and retrieving one logged-on user in PowerShell. Let’s learn both interpretations. 1. Introduction to the Problem Statement In network and system administration, it’s often necessary to determine which users are currently logged on to a system. This information can be critical for security, auditing, […]

  • Append data to file using PowerShell
    03 May

    Append Data to File using PowerShell

    Appending Text to a Text File We have various approaches to append content in a text file using PowerShell. For example, we can append information on the same line, on a new line with/without special characters, on multiple lines, and append formatted data such as tabular content. But, before moving towards possible solutions, it is […]

  • Check if argument exists in PowerShell
    02 May

    Check if Arguments Exists in PowerShell

    In PowerShell, it is essential to check whether arguments exist, especially when creating scripts that take input parameters. However, before delving into the specifics of developing a PowerShell script that accepts arguments and checks for their presence, learning how to create a script .ps1 file within a directory is essential. You need to go through […]

  • Combine multiple conditions in if statement in PowerShell
    02 May

    Combine Multiple Conditions in if Statement in PowerShell

    We use an if statement with logical operators and comparison operators to combine multiple conditions in PowerShell. We also use parentheses represented by (()) to group conditions and control the evaluation order. So, it is essential to know what logical, arithmetic and comparison operators we have, what they mean and what they can do. See […]