Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

All Users Report

$
0
0

Dear,

I am looking for a script that could generate ALL users report which should include:

DN, CN, FirstName, LastName, DisplayName, Email , TelephoneNumber, Mobile, Description, Office ,pwdLastSet, pwage, whenCreated, strAccountExpirationDate, userAccountControl, lastLogonTimeStamp, Disabled, Itsage, Site

 

I have a script which does give me few attribute, what Can I add more in my scipt to generate other attributes?

Here's my script:

--------------------------

$NumDays = 0

$LogDir = "e:\script\User-Accounts.csv"

$currentDate = [System.DateTime]::Now

$currentDateUtc = $currentDate.ToUniversalTime()

$lltstamplimit = $currentDateUtc.AddDays(- $NumDays)

$lltIntLimit = $lltstampLimit.ToFileTime()

$adobjroot = [adsi]''

$objstalesearcher = New-Object System.DirectoryServices.DirectorySearcher($adobjroot)

$objstalesearcher.filter = "(&(objectCategory=person)(objectClass=user)(lastLogonTimeStamp<=" + $lltIntLimit + "))"

$users = $objstalesearcher.findall() | select `

@{e={$_.properties.cn};n='Display Name'},`

@{e={$_.properties.samaccountname};n='Username'},`

@{e={[datetime]::FromFileTimeUtc([int64]$_.properties.lastlogontimestamp[0])};n='Last Logon'},`

@{e={[string]$adspath=$_.properties.adspath;$account=[ADSI]$adspath;$account.psbase.invokeget('AccountDisabled')};n='Account Is Disabled'}

$users | Export-CSV -NoType $LogDir

------------------------------------------

Thanks

 

 


Viewing all articles
Browse latest Browse all 8583

Trending Articles