ps-getleftuserstatus

Title: Get the User Profile status for left users.

Description: Take the left users information in txt file. the file will compare with user profile data and will show whether profile deleted or not.

  • ##################################################################################  
  • #  Script name:GetLeftUSersProfilesReport.ps1  
  • #  Purpose: Get the list of all Left USers inforation from USer profile  
  • #  Script Written by :Bramhendra LAkku  
  • # Modified and Approved by :  
  • #  
  • #  Input Parameters Format : .\GetLeftUSersProfilesReport.ps1   
  • #  Out Put: Output file will generated in this Folder  
  • ##################################################################################  
  •  
  •  
  • #Add SharePoint PowerShell SnapIn if not already added   
  • if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {   
  •     Add-PSSnapin "Microsoft.SharePoint.PowerShell"   
  • }  
  • # Parameters  
  • $csvFilename = "F:\LB\test.txt"   
  • $site = new-object Microsoft.SharePoint.SPSite("http://people.in.lakku.com/");   
  • $Accountdomain="account-01"  
  • # End Parameters  
  •   
  • $start_count = 0;   
  • $ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);   
  • $date = Get-Date -format MMddyyy   
  • $OutPutFilename="UserprofileForLeftUsers-$date.csv";  
  • "Dnumber" + "," +"Status" | Out-File -Encoding Default -FilePath $OutPutFilename;  
  •    
  •  $csv = Import-Csv $csvFilename -Header @("Userid")   
  • #Get UserProfileManager from the My Site Host Site context   
  • $ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)   
  •   
  •       
  •     foreach ($line in $csv)   
  •     {  
  •     $start_count++;  
  •     $Dnumber=$line.Userid;  
  •     $DnumberDomain=$Accountdomain+"\"+$Dnumber  
  •      
  •      
  •  #$Dnumber="domain\userid"  
  •  if($Dnumber -ne  "")  
  •      {  
  •         
  •     Write-Progress -Activity "Please wait Report is generating" -Status "Profile order $start_count checking from your input file"  
  •   
  •   
  •         if($ProfileManager.UserExists($DnumberDomain))  
  •             {  
  •   
  •                 $Dnumber + ", " + "User left but Profile there"    | Out-File -Encoding Default  -Append -FilePath $OutPutFilename;  
  •             }  
  •         }  
  •    }  
  •