See users without employee ID in SharePoint

Add-PSSnapin Microsoft.Sharepoint.Powershell

# Dynamic Settings

$mySiteUrl = “URL

$findProperty = “employeeID”

$bodytxt = “UserswithoutemployeeID”

$smtpserver = “XXXXX”

$Attachfile = “C:\Employeeid.csv”

$Emailto = “XXXXX”

$EmailSubject = “NoEmployeeID”

#start-transcript Employeeid.csv

start-transcript -path D:\PowerShell\Employeeid.csv-force

# Obtain Context based on site

$mySiteHostSite = Get-SPSite $mySiteUrl

$mySiteHostWeb = $mySiteHostSite.OpenWeb()

$context = Get-SPServiceContext $mySiteHostSite

# Obtain Profiles from the Profile Manager

$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)

$AllProfiles = $profileManager.GetEnumerator()

$outputCollection = @()

# Loop through profiles and retrieve the desired property

foreach ($profile in $AllProfiles)


$output = New-Object System.Object

$output | Add-Member -type NoteProperty -Name AccountName -Value $profile[“AccountName”].ToString()

$output | Add-Member -type NoteProperty -Name $findProperty -Value $profile[$findProperty]

$outputCollection += $output


# List all Accounts that do not contain the property

$outputCollection | Where-Object {[bool]$_.($findProperty) -ne $true}


Send-MailMessage -To $Emailto -Subject $EmailSubject -from “your mail” -Body $bodytxt -SmtpServer $smtpserver -Attachments $Attachfile

Thanks for following

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s