aboutsummaryrefslogtreecommitdiffstats
path: root/AD-powershell-tools/ad-user-report.ps1
blob: 954a34a4424d6304d950a5ca92b842c75a7e8d45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Simple user report script
param (
        [switch]$report
        )

Import-Module ActiveDirectory

$today=(get-date -Format "yyyy-MM-dd")
$users = Get-ADUser -filter * | Sort-Object name

if($report) {
        $fn = "users-$today.csv"
        $users | export-csv .\$fn
        [Console]::Error.WriteLine("Saved result list to $fn")
} else {
        [Console]::Error.WriteLine("Writing device list to stdout")
        write-output $users
}