Thursday, July 10, 2025
HomePowershellHow one can discover empty Attributes – SID-500.COM

How one can discover empty Attributes – SID-500.COM


PowerShell

We are sometimes on the lookout for attributes, however what concerning the empty attributes? How can I discover out if an attribute is empty? That’s the focus of this text. I’ll present a sensible instance of discover these empty attributes.

Let’s begin with discover attributes that are NOT empty. The next code retrieves all svchost course of Attributes which have a worth.

$course of = Get-Course of -Identify "svchost" | Choose-Object -First 1
$course of.PSObject.Properties | The place-Object { $null -eq $_.Worth } | Choose-Object Identify, Worth

In search of Empty Attributes

Now we’re on the lookout for empty attributes.

$course of.PSObject.Properties | The place-Object { $null -ne $_.Worth } | Choose-Object Identify, Worth

As you possibly can see, within the first instance we’ve got known as attributes that aren’t empty and within the second instance we’ve got known as attributes which are empty.

A extra sensible instance is the seek for empty attributes for Lively Listing customers.

Right here is an instance:

# Which customers have empty streetaddress?
$property = 'streetaddress'
Get-ADUser -Filter * -Properties $property | The place-Object { $null -eq $_.$property } | 
Choose-Object Identify, $property

Printed by Patrick Gruenauer

Microsoft MVP on PowerShell [2018-2025], IT-Coach, IT-Marketing consultant, MCSE: Cloud Platform and Infrastructure, Cisco Licensed Academy Teacher.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments