• 29 August

    Bash Replace Space with Newline

    If you have multiple consecutive spaces in the string, use the last solution, the for loop. You can use any of the following solutions if you have a multiline string. Using tr Command Use the tr command to replace space with newline in bash. text="This is a sample string." new_text=$(echo "$text" | tr ' ' […]

  • PowerShell get password expiration date
    16 August

    Get Password Expiration Date in PowerShell

    Using Get-ADUser Cmdlet Use the Get-ADUser cmdlet to get the password expiration date for one specific user in an Active Directory. Get-ADUser -Identity Administrator –Properties "SamAccountName", "msDS-UserPasswordExpiryTimeComputed" | Select-Object -Property "SamAccountName", @{Name="PasswordExpiryDate";Expression={[DateTime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} SamAccountName PasswordExpiryDate -------------- ------------------ Administrator 8/27/2023 4:35:46 PM The Get-ADUser cmdlet is used to get one or multiple users from an active directory. […]

  • PowerShell get ad user home directory and home drive
    16 August

    Get AD User Home Directory and Home Drive in PowerShell

    Using Get-ADUser Cmdlet We use Get-ADUser differently based on various use cases; let’s explore a few of them below. Get Home Directory & Drive for One User Use the Get-ADUser cmdlet to get the ad user’s home directory and home drive. $username = 'Administrator' Get-ADUser -Identity $username -Properties * | Select HomeDirectory, HomeDrive HomeDirectory HomeDrive […]

  • Bash Check if boolean is true
    02 August

    Check If Boolean Is True in Bash

    Using if Statement We can use an if statement with different variations to determine whether the provided Boolean variable is true. Note that the examples covered in this section will be similar. We will learn the first example in Use if with true Condition in detail, but later, we will discuss the section which will […]

  • PowerShell round to whole number
    03 June

    PowerShell Round to Whole Number

    Using [Math]::Round Method Use the [Math]::Round to round number to whole number in PowerShell. $decimalNum = 3.14159 $roundedNum = [Math]::Round($decimalNum, 0) Write-Host "Original number: $decimalNum" Write-Host "Rounded number: $roundedNum" Original number: 3.14159 Rounded number: 3 We can observe the [Math]::Round method rounds a decimal number to the nearest whole number. In PowerShell, the [Math]::Round method […]

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.