• PowerShell break foreach loop
    27 May

    PowerShell Break ForEach Loop

    Usually, learners get confused with ForEach and ForEach-Object while using break/continue statements in PowerShell, but there is a clear difference between the ForEach loop and ForEach-Object cmdlet, that’s why break/continue statements do not work in ForEach-Object cmdlet as they work in ForEachLoop. We will learn about both statements in this article, but before diving into […]

  • 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-662e027f6590d948186227/] [crayon-662e027f65912828776963/] 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-662e027f65913066789195/] [crayon-662e027f65914423540942/] 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-662e027f65ba7627200757/] [crayon-662e027f65bab079137055/] 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-662e027f66311381018737/] [crayon-662e027f66316364234025/] 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 […]

  • Bash Check if Grep result is empty
    11 May

    Bash Check If grep Result Is Empty

    All the code snippets are written in the MyScript.sh file, while the dummy.txt file contains some sample data we used in our scripts. Using -q Option with grep Use the -q option with grep to check if the grep command result is empty. [crayon-662e027f66955405272605/] [crayon-662e027f66959827253359/] [crayon-662e027f6695b027964885/] [crayon-662e027f6695c536394119/] In the above example, the grep command searched […]

  • 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-662e027f66b9c104761594/] [crayon-662e027f66b9f897362537/] 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 […]

  • Count unique values in numpy array
    04 May

    Count Unique Values in NumPy Array

    1. Introduction One of the common tasks Numpy Users may encounter is count unique values in Numpy Array that can help in exploring the distribution of Nummy Array. In this article, we will see different ways to count unique values in Numpy Array. 2. Using np.unique() Method with len() Method Use np.unique() method with len() […]

  • Create array of arrays in Python
    04 May

    Create Array of Arrays in Python

    Use numpy.array() Function To create an array of the arrays in Python: Use the np.array() function to create a numpy.ndarray type array of the arrays. [crayon-662e027f66f51855446018/] [crayon-662e027f66f54280602007/] The Python library NumPy scientifically computes advanced numerical work. It is a language extension that adds support for large, multi-dimensional arrays and matrices in the Python language. The […]

  • Bash add character to String
    04 May

    Bash Add Character to String

    We can also use these methods to add a string to the given string as well. Using $ Operator Use the $ operator to add character to string in Bash. [crayon-662e027f67044802605730/] [crayon-662e027f67046713150273/] the${str} is used to expand the value of the str variable and then appends the string o to it, resulting in the string […]