powershell - How to show all value that have a null entry in a specific column -


i wanting bring forward csv file containing users name, samaccountname , description, have noticed there several people not have descriptions. looking how edit existing code (i know there's simple way can't remember it) filters output shows users have no description.

get-aduser -filter * -properties name,samaccountname,description -searchbase "dc=removed,dc=com" | ? { $_.enabled -notlike "false" } |  select name,samaccountname,description | export-csv "c:\scripts\nodescriptionusers.csv" 

you need add condition in where-object scriptblock since can't filter empty values ldap-query afaik. 1 suggestion:

get-aduser -filter * -properties name,samaccountname,description -searchbase "dc=removed,dc=com" | ? { $_.enabled -notlike "false" -and [string]::isnullorempty($_.description.trim()) } | select name,samaccountname,description | export-csv "c:\scripts\nodescriptionusers.csv" 

personally move enabled-check filter in get-aduser speed things up. dc send enabled users instead of users. try:

get-aduser -filter { enabled -eq $true } -properties name,samaccountname,description -searchbase "dc=removed,dc=com" | ? { [string]::isnullorempty($_.description.trim()) } | select name,samaccountname,description | export-csv "c:\scripts\nodescriptionusers.csv" 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -