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
Post a Comment