Quantcast
Channel: Directory Services forum
Viewing all articles
Browse latest Browse all 31638

ADLDS query

$
0
0

First let me say that I have almost no experience with powershell.  I know how to dump some code in to a .ps1 file to be run like a batch file.  Here is what I'm trying to figure out.

We're going to be using an ADLDS attribute, "Description", to add data for which type of application someone uses on our site, and separate those applications with semi colons.

Example app1;app2;app3;app4

I need a script that will read this attribute and parse those apps in to variables, then execute something based on the variable.

Example: I need to see if a user has app2 in the user account description field, see if their account is enabled, and if their account is enabled, , pull them in to a csv file, then email that file to a distribution list. 

So I end up with a csv file listing how many users have app1 or app2.

Any help is greatly appreciated.

here is a script that seems to work to pull some of that data from ADAM.

Get-ADObject -Server 'localhost:389' -SearchBase 'CN=Users,CN=WAP,DC=domain,DC=COM' -Filter 'description -like "*"' -properties DisplayName,lastlogontimestamp, description | select Name, description, `
        @{Name="LastLogonTimeStamp";Expression={([datetime]::FromFileTime($_.LastLogonTimeStamp))}},`
    @{Name="pwdLastSet";Expression={([datetime]::FromFileTime($_.pwdLastSet))}} | export-csv c:\temp\userauditlast4.csv -NoTypeInformation

This also pulls last logon timestamp, and last time password reset, which I really don't need.


Viewing all articles
Browse latest Browse all 31638

Trending Articles