Send-MailMessage –From Guruprasad_Marathe@aaa.com –To Guruprasad_Marathe@aaa.com –Subject “Test Email” –Body “Test E-mail (body)” -SmtpServer mailserver.aaa.com
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.aaa.com
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)
Tuesday, May 6, 2014
Discovering or Reports on the items permissions for SharePoint Library or List PowerShell script
Clear-Host
if((Get-PSSnapin | where{$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{
Add-PSSnapin Microsoft.SharePoint.PowerShell;
Write-Host "Snap In Added";
}
$SiteUrl = "<site url>/sites/ags/spg/pit/pitsite";
Function GetFiles($folder)
{
# Use recursion to loop through all subfolders.
foreach ($spFolder in $folder.SubFolders)
{
if($spFolder.Name -ne 'Forms')
{
if($spFolder.Item.HasUniqueRoleAssignments)
{
$roleAssignments = $spFolder.Item.RoleAssignments;
if ($roleAssignments.Count -gt 0) {
foreach ($role in $roleAssignments){
$eachRole = $role.Member.ToString();
$allRoles += $eachRole + ";";
}
$url=$SiteUrl+"/"+$spFolder.Url
#$link = "<a href=" + $url + ">" +$url + "</a>";
$OutInfo = $spFolder.Name + "," + $url + "," + "No" + "," + $allRoles;
Add-Content -Value $OutInfo -Path $OutFile
}
}
else
{
$url=$SiteUrl+"/"+$spFolder.Url
$OutInfo = $spFolder.Name + "," + $url + "," + "Yes" + "," + "";
Add-Content -Value $OutInfo -Path $OutFile
}
}
GetFiles($spFolder)
}
}
$OutFile = "D:\test\Permissions.csv"
$Header = "Folder Name,Folder URL,IsInherited,Permissions"
Del $OutFile
Add-Content -Value $Header -Path $OutFile
$web = Get-SPWeb -Identity "<site url>sites/ags/spg/pit/pitsite"
$list = $web.GetList("<siteurl>/sites/ags/spg/pit/pitsite/Shared Documents")
GetFiles($list.RootFolder)
Monday, December 2, 2013
Parent & Child items in SharePoint 2010 OOTB through SPD
Requirement.
many times we get requirement to create child items for the mail parent list item, for example. you have issues [Parent list] and you want to logs to those issues [Child list]
This blog is for one of the person who took my interview [MindTree Ltd] and by my answers he was surprised and could not able to believe my solution. I told it is possible through OOTB with nice UI but he was confused and could not able to believe.
he estimated it may take 2 to 3 weeks to do it. but I achieved within 6 hours.
I will put snap shots first and the code how I did.
Create Parent Item: [ note: I m not hiding SP default buttons so that people don’t confuse how I did it]
in parent list I have just Title, I have provided Save and continue button, until we create parent. we cannot create child ![]()
<input type="button" value="Save and Continue" name="btnSave" class="ms-ButtonHeightWidth"/>
$(document).ready(function() {
$('input[name="btnSave"]').click(function(){CreateNewItem();});
});
function CreateNewItem()
{
debugger;
var tit = $('input[title="Title"]').val();
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "New",
listName: "Parent List",
valuepairs: [["Title", tit]],
completefunc: function (xData, Status) {
var newID = $(xData.responseXML).find("z\\:row").attr("ows_ID");
if(newID == null || newID*1<1)
{
alert("\nThere was an error in creating item.");
return;
}
else
{
window.location = "editparent.aspx?ID="+newID;
}
}
});
}
</script>
after saving the parent I am shifting the page from new form to edit form of same item, parents save and cancel button I am not hiding.]
note: I have added 2 save function, two way you can save the item
function Save()
{
debugger;
saveStatus=true;
preSaveStatus=true;
var buttonName = $("input[id$='diidIOSaveItem']")[0].name;
if (!PreSaveItem())
return false;
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(buttonName, "", true, "", "", false, true));
}I have added a button called create child entry. which pop ups child’s newform and after saving that item come below the edit form of parent. below create child button I have list view there I filter with parent ID ie id of the parent I am storing it in every child, I am sending this parent ID through query string
http://<server>/sites/PST/Guru%20RnD/Lists/Child%20List/newChild.aspx?ParentQSID=22&IsDlg=1
once you save I have refresh the parent page so this item get filtered in the below list view
<input type="button" class="ms-ButtonHeightWidth" value="Create a new Child Entry..." onclick="CreateChild();"/>
this code in parent edit form.
function CreateChild()
{
var parentID = getParameterByName("ID");
//Using a generic object.
var options = {
title: "My Dialog Title",
width: 800,
height: 600,
url: "../../Lists/Child%20List/newChild.aspx?ParentQSID="+parentID,
dialogReturnValueCallback: function(dialogResult)
{
SP.UI.ModalDialog.RefreshPage(dialogResult)
}
};
SP.UI.ModalDialog.showModalDialog(options);
}
CHILD NEW FORM
I am setting parent id in child through SPD designer
<asp:Textbox runat="server" id="ff2{$Pos}" text="{$varParentID}" ControlMode="New" FieldName="ParentID" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@ParentID')}"/>
Tuesday, November 5, 2013
Attachment & files [pdf, zip] are not prompting to Open in SharePoint 2010, only saved, not opening OR [file does not show open]
one of my customer raised a issue regarding file does not prompt to open the files in SharePoint site, mostly pdf and zip files
yes it is a issue, if files does not opens why to maintain database. !!
The Solution
It is a simple web application setting ,The setting is called Browser File Handling and can be found in the General Settings of the web application.
CA> webapplication> general settings> Browser file handling > make it to Permissive
problem solved !! if you read a blog don’t forget to comment plzz
Monday, October 14, 2013
Showing different values in SharePoint all item views in only in view based on configuration list [currency, Exchange date] defined
Create two list,
Requirement:
I have 1 list with key | Exchange Rate two columns
List 1:
| key | Exchange Rate |
| A | 0.5 |
| B | 2 |
| C | 2 |
| D | 3 |
>>>>>>>>>
List 2: another list Amount List Key Amount
| key | Amount |
| A 1000 | 1000 |
| A 2000 | 2000 |
| B 3000 | 3000 |
whenever users open any particular view (example test.apsx) of second list ( customized in SPD)
I have to get below results depending upon the exchange rate defined in configuration list 1
I,e exchange rate * Amount
| key | Amount |
| A | 500 |
| A | 1000 |
| B | 6000 |
Report has been implemented in my test site, follow the process to do it. Make you’re your configuration list currency will be look up with
multiplied value
1) Select your column to multiple in any newly created new, select formula on the top
2)
3) Multiply the value with the current node as per the snap shot
4)
Showing different values in SharePoint all item views in only in view based on configuration list [currency, Exchange date] defined
Create two list,
Requirement:
I have 1 list with key | Exchange Rate two columns
List 1:
| key | Exchange Rate |
| A | 0.5 |
| B | 2 |
| C | 2 |
| D | 3 |
>>>>>>>>>
List 2: another list Amount List Key Amount
| key | Amount |
| A 1000 | 1000 |
| A 2000 | 2000 |
| B 3000 | 3000 |
whenever users open any particular view (example test.apsx) of second list ( customized in SPD)
I have to get below results depending upon the exchange rate defined in configuration list 1
I,e exchange rate * Amount
| key | Amount |
| A | 500 |
| A | 1000 |
| B | 6000 |
Report has been implemented in my test site, follow the process to do it. Make you’re your configuration list currency will be look up with
multiplied value
1) Select your column to multiple in any newly created new, select formula on the top
2)
3) Multiply the value with the current node as per the snap shot
4)