Author: Arpit Mandliya
- 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 […]
- 27 May
PowerShell Add Quotes to String
Using Backtick Characters Use backtick characters to add double quotes to string in PowerShell. [crayon-67686205cfdb0531214720/] [crayon-67686205cfdb6430334511/] 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-67686205cfdb7209593324/] [crayon-67686205cfdb9526335779/] Using String Concatenation Operator Use string concatenation operator […]
- 27 May
PowerShell Add Array to Array
Using + Operator Use the + operator to add an array to another array. [crayon-67686205d0cc5358497391/] [crayon-67686205d0ccb530913508/] 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 […]
- 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-67686205d1bef871705279/] [crayon-67686205d1bf5745845649/] 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 […]
- 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-67686205d1db0778315932/] [crayon-67686205d1db3160379106/] [crayon-67686205d1db4999004505/] [crayon-67686205d1db5452229228/] In the above example, the grep command searched […]
- 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-67686205d1fb8232825705/] [crayon-67686205d1fbe851451355/] 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
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() […]
- 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-67686205d2361283929128/] [crayon-67686205d2364915825637/] 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 […]
- 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-67686205d261c969008343/] [crayon-67686205d2620782644551/] the${str} is used to expand the value of the str variable and then appends the string o to it, resulting in the string […]