Test-QADObject by Dmitry Sotnikov 22 months ago
embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1717"></script>download | new post
Check if the AD object/path exists. Accepts DN, SID, GUID, UPN, samAccountName, Name or Domain\Name. Returns $true or $false.
Requires Quest AD cmdlets which are a free download from http://www.quest.com/activeroles-server/arms.aspx.
(c) Dmitry Sotnikov, http://dmitrysotnikov.wordpress.com
- <#
- .SYNOPSIS
- Quick way to see whether the object exists in AD.
- .DESCRIPTION
- Returns $true if at least one object matching the criteria exists and false otherwise.
- .PARAMETER Identity
- Specify the DN, SID, GUID, UPN or Domain\Name of the directory object you want to find
- .EXAMPLE
- PS C:\> Test-QADObject dsotniko
- .EXAMPLE
- PS C:\> Test-QADObject 5ae7197e-cac3-42bf-9541-e06fa33ed965
- .EXAMPLE
- PS C:\> Test-QADObject 'OU=demo,DC=quest,DC=local'
- .INPUTS
- System.String,System.String[]
- .OUTPUTS
- System.Boolean
- .NOTES
- (c) Dmitry Sotnikov, http://dmitrysotnikov.wordpress.com
- Requires Quest AD cmdlets which are a free download from
- http://www.quest.com/activeroles-server/arms.aspx
- .LINK
- Get-QADObject
- #>
- function Test-QADObject {
- [CmdletBinding()]
- param(
- [Parameter(Position=0, Mandatory=$true)]
- [System.String]
- $Identity
- )
- (Get-QADObject $Identity -DontUseDefaultIncludedProperties `
- -WarningAction SilentlyContinue -ErrorAction SilentlyContinue `
- -SizeLimit 1) -ne $null
- }
- Set-Alias -Name Test-QADPath -Value Test-QADObject
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
PowerShell Code Repository