-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExport-SamAccountNames.ps1
More file actions
40 lines (30 loc) · 1.1 KB
/
Export-SamAccountNames.ps1
File metadata and controls
40 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# This script will export a list of SAMAccountNames and their
# respective email addresses for import into a SkyKick project.
# This will assist in silent deployment of the Outlook Assistant.
#
# nathan@diverse.services 10092019
#
# Usage:
# .\Export-SamAccountNames.ps1 -CSVPath C:\Temp\UserList.csv
# This will dump the list of entries to C:\Temp\UserList.csv
#region Script Parameters
# -----------------------
[CmdletBinding(SupportsShouldProcess=$True)]
Param (
[parameter(
Mandatory=$true,
HelpMessage='Path to where the CSV should be exported')]
[string]$CSVPath
)
Import-Module ActiveDirectory
#endregion
#region Variables
#----------------
$a=@{Expression={$_.EmailAddress};Label="SourceEmailAddress"}, `
@{Expression={$_.SamAccountName};Label="SourceSAMAccountName"}
#endregion
#region Program
#--------------
$AllUsers = get-aduser –filter * -properties *
$AllUsers | where-object {$_.EmailAddress -ne $null -and $_.EmailAddress -NotLike "*.local" -and $_.Enabled -eq $True} | Select-Object $a | export-csv -path $CSVPath –notypeinformation
#endregion