PowerShell kullanarak "Oluşturan" Liste Öğesinden Kullanıcı E-posta Adresini Alın


PowerShell otomasyon çalışması için belirli bir liste öğesini oluşturan kullanıcının E-posta Kimliğini almam gerekiyordu. Alan tarafından oluşturulan E-posta kimliğini almak için kullanışlı PowerShell betiği:


Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

#Function to get User's Email from User ID 
Function GetUserEmail($UserValue)
{
    #Uservalue: E.g: "1;#user name";
 $arr = $UserValue.Split(";#");
 $UserID = $arr[0];
 $user = $web.SiteUsers.GetById($UserId); 
 #the above line returns: SPUser Object
 
 return $user.Email
}

$WebURL ="https://sharepoint.crescent.com/SharePointSupport/"
$ListName ="Site Requests"

#Get the Web and List 
$Web = Get-SPWeb $WebURL  
$list = $web.Lists[$ListName]

#Get an Item by id
$item = $list.GetItemByID(1)

 #Get Created by User details
 #$item["Author"] Returns something like: 3;#Salaudeen
 $CreatorMail = GetUserEmail($item["Author"])

 Write-Host $CreatorMail

Aynı şey, kullanıcı e-posta adreslerini programlı olarak almak için C#'ta da yapılabilir.

İlgili makaleler