ps-compareup-txt

Title: Compare txt file data with user profile

Description:  Take the each userid from txt file and compare the status in  the user profile

  1. $csvFilename = "C:\Users\lakku\Desktop\mysite\test.txt"   
  2. $csv = Import-Csv $csvFilename -Header @("Userid")  
  3.   
  4.   
  5.       
  6.    # ========  
  7.       
  8.     #Add SharePoint PowerShell SnapIn if not already added   
  9. if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {   
  10.     Add-PSSnapin "Microsoft.SharePoint.PowerShell"   
  11. }  
  12.   
  13. $site = new-object Microsoft.SharePoint.SPSite("http://people.in.lakku.com.au/");    
  14. $ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);    
  15.    
  16. #Get UserProfileManager from the My Site Host Site context   
  17. $ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)      
  18. $AllProfiles = $ProfileManager.GetEnumerator()    
  19.    
  20. foreach($profile in $AllProfiles)    
  21. {    
  22.     $DisplayName = $profile.DisplayName    
  23.     $AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value   
  24.     #############################################  
  25.       
  26.     foreach ($line in $csv) {  
  27.     $Dnumber=$line.Userid;  
  28.   
  29.     #Write-Host "ServerName=$line.ServerName  ServiceName=$line.ServiceName"   
  30.     Write-Host $Dnumber  
  31.     #Write-Host ('Name={0}   Phone={1}' -f $line.Name,$line.Phone)  
  32.     }  
  33.     ###############################################   
  34.    
  35.      
  36.     #if($AccountName -ne "domain\userid")   
  37.     if($AccountName -eq $Dnumber)   
  38.     {   
  39.           
  40.         write-host "Profile  ", $AccountName, " is there "   
  41.     }  
  42.     }