search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Checking Active Directory OU with Powershell
Posted in Windows Powershell, Windows Server | No Comment | 3,772 views | 16/08/2009 20:28

This is my custom Powershell script to check OU in Active Directory.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function Check-CustomerOU
{
param ($CustomerID, $CustomerOU)
 
    $FQDN = (Get-ADInfo).FQDN
 
    $CustomerOU = [ADSI] "LDAP://OU=$CustomerID,$CustomerOU,$FQDN"
 
    If(!$CustomerOU)
    {
        Write-Host "No such Organizational Unit on the Server" | Out-Null
        $Status = "0"
    }
    Else
    {
        Write-Host "Organizational Unit exist on the Server" | Out-Null
        $Status = "1"
    }
 
    $Results = New-Object Psobject
    $Results | Add-Member Noteproperty Status $Status
    Write-Output $Results    
}

As you see, it is too easy to check an Active Directory OU with Powershell.



Leave a Reply