• 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 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. $computer_name = $env:COMPUTERNAME $fqdn = $env:USERDNSDOMAIN Write-Output "Fully Qualified Domain Name: $computer_name.$fqdn" Fully Qualified Domain Name: MAS-DC-01.MASLAB.COM 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 […]

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

  • 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, […]

  • PowerShell get ad user account expiration date
    15 April

    PowerShell Get Ad User Account Expiration Date

    Using Get-AdUser Cmdlet with Select-object cmtlet Use the Get-AdUser with Select-object to get the ad user account expiration date in PowerShell. Get-ADUser -Identity "JohnDoe" -Properties AccountExpirationDate | Select-Object AccountExpirationDate AccountExpirationDate --------------------- 7/1/2022 12:00:00 AM Here, the PowerShell cmdlet Get-ADUser was used to retrieve the information about the users of the Active Directory as it is […]

  • 24 December

    Get AD User Description in PowerShell

    To get AD user description in powerShell, use Get-AdUser cmdlet with -Properties as Description. Import-Module ActiveDirectory Get-ADUser -Identity marion -Properties Description -Expand Description Please note that you must must first install the Remote Server Administration Tools (RSAT) package and import the Active Directory module. Get AD User Description and Attributes in PowerShell The Get-ADUser cmdlet […]

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.