Title: Compare txt file data with user profile
Description: Take the each userid from txt file and compare the status in the user profile
Description: Take the each userid from txt file and compare the status in the user profile
- $csvFilename = "C:\Users\lakku\Desktop\mysite\test.txt"
- $csv = Import-Csv $csvFilename -Header @("Userid")
- # ========
- #Add SharePoint PowerShell SnapIn if not already added
- if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
- Add-PSSnapin "Microsoft.SharePoint.PowerShell"
- }
- $site = new-object Microsoft.SharePoint.SPSite("http://people.in.lakku.com.au/");
- $ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);
- #Get UserProfileManager from the My Site Host Site context
- $ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)
- $AllProfiles = $ProfileManager.GetEnumerator()
- foreach($profile in $AllProfiles)
- {
- $DisplayName = $profile.DisplayName
- $AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value
- #############################################
- foreach ($line in $csv) {
- $Dnumber=$line.Userid;
- #Write-Host "ServerName=$line.ServerName ServiceName=$line.ServiceName"
- Write-Host $Dnumber
- #Write-Host ('Name={0} Phone={1}' -f $line.Name,$line.Phone)
- }
- ###############################################
- #if($AccountName -ne "domain\userid")
- if($AccountName -eq $Dnumber)
- {
- write-host "Profile ", $AccountName, " is there "
- }
- }