locked
Need PowerShell command to fetch "Disabled users" from my csv file RRS feed

  • Question

  • Hi All,

    I hope you will help me.

    I have to fetch Disabled users from my csv file that has all users account of my AD. The output should be piped to csv file. Due to the beginner for PowerShell, I don't know this. Please help me for this issue. Thanks. 

    Friday, August 16, 2019 1:12 PM

Answers

  • If you use a input file with a column name SamAccountName
    Import-CSV -Path "C:\Filepath\file.txt" | Get-ADUser -Identity $_.SamAccountName -Filter * -Property Enabled  | Select Name, Enabled  | Export-CSV -NoTypeInformation -Path "C:\Filepath\file.txt" 

    If you retreive all users from AD:
    Get-ADUser -Filter * -Property Enabled | Select Name, Enabled  | Export-CSV -NoTypeInformation -Path "C:\Filepath\file.txt" 
    Friday, August 16, 2019 1:24 PM

All replies