Saturday, August 29, 2015

Sending email from PowerShell

 

Send-MailMessage –From Guruprasad_Marathe@aaa.com –To Guruprasad_Marathe@aaa.com –Subject “Test Email” –Body “Test E-mail (body)” -SmtpServer mailserver.amat.com

 

Technorati Tags: ,,

PowerShell to unlock the files which are locked from SharePoint

 

 

$web = Get-SPWeb http://<site>/Ringo

$list = $web.Lists["Shared Documents"]

$item = $list.GetItemById(171)

$file = $item.File

$file

$userId = $file.LockedByUser.ID

$user = $web.AllUsers.GetByID($userId)

$impSite= New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken);

$impWeb = $impSite.OpenWeb();

$impList = $impWeb.Lists[$list.Title]

$impItem = $impList.GetItemById($item.ID)

$impFile = $impItem.File

$impFile.ReleaseLock($impFile.LockId)