Skip to content

Instantly share code, notes, and snippets.

View emiliano-poggi's full-sized avatar

Emiliano Poggi emiliano-poggi

View GitHub Profile
@emiliano-poggi
emiliano-poggi / .ps1
Created March 22, 2018 10:10
Bypass proxy in powershell session
$Creds=Get-Credential
$Wcl=New-Object System.Net.WebClient
$Wcl.Proxy.Credentials=$Creds
@emiliano-poggi
emiliano-poggi / httpdownload.ps1
Last active March 31, 2017 13:27
Download file from web using Powershell
$webCli = new-object System.Net.WebClient
$webCli.Credentials = [System.Net.CredentialCache]::DefaultCredentials
# $webCli.Credentials = new-object System.Net.NetworkCredential(user,pwd,domain)
$webCli.DownloadFile($FileUrl, $LocalFilePath)
@emiliano-poggi
emiliano-poggi / 0.md
Last active May 9, 2016 11:20
Fix SharePoint 2013 Field Link missing from List Content Type, Lookup Field, Additional Fields

Fix SharePoint 2013 Field Link missing from List Content Type, Lookup Field, Additional Fields

You have a List Content Type with a Lookup Field for which you cannot set additional lookup fields from the User Interface.

You can use Powershell (server side) to set the additional lookup fields by explicitely adding a field link object to the target list content type.

@emiliano-poggi
emiliano-poggi / 0.md
Last active February 18, 2016 08:49
SharePoint 2013 Powershell How To Update Modify Lookup Column Field References

SharePoint 2013 Powershell How To Update Modify Lookup Column Field References

When you delete a list referenced from a lookup field, the field stops working, even if you recreate the list with the same name. This is due to the fact that the lookup field referneces the list by ID and not by Title.

Even if from UI interface you can't edit a column definition of a lookup field, you can easily change the lookup definition using Powershell.

The following snippet shows how to change the lookup list and display value of a site column definition. The trick is to work on the XMLSchema of the field and then update the field definition. Note: if you have defined in your lookup field to show additional fields, you have to reset the lookup list for these fields too.

@emiliano-poggi
emiliano-poggi / 0.md
Last active May 11, 2021 01:27
How To PowerShell Active Directory Query using ADSISearcher, no ActiveDirectory module

How To PowerShell Active Directory Query using ADSISearcher

Create the new adsisearcher object:

$searcher = [adsisearcher]""

Test searcher:

$searcher.SearchRoot()
@emiliano-poggi
emiliano-poggi / 0.md
Last active May 22, 2020 20:35
SharePoint 2013 Pass Parameter to New Form to Populate Lookup Field

SharePoint 2013 Pass a Parameter through URL to New Form

You want to pass a parameter value through URL to a new form and populate a field of the item (in this example a lookup field).

  1. Using SPD, create a New Form aspx page (you can also work directly on the NewForm.aspx page).
  2. Using the browser, connect to the aspx page and click Edit.
  3. Insert the Script Editor web part and add the relevant code (see below)
  4. Stop Editing the page (it will be automatically saved), and Cancel the form.

Now, you will be able to call the web page using URL parameter YourField:

@emiliano-poggi
emiliano-poggi / 0.md
Last active August 29, 2015 14:15
SharePoint 2013 Visual Studio Team Foundation Web Parts How To Automatically Refresh Query Results Without Postback Action

SharePoint 2013 Visual Studio Team Foundation Web Parts How To Automatically Refresh Query Results Without Postback Action

You want to refresh the Query Results web parts of Visual Studio Team Foundtion embedded into a web part page, so that every 3 seconds the user has a query updated without having to refresh the entire page. Obviously you want automatically refresh the single web part, not the entire web page.

  1. In Edit mode, search in the web page runtime elements for the keyword "Refresh Results". You should find one or more ie:menuitem elements, many elements as many Query Results web parts you have. See the snippet_menuitem.html below for an example.
  2. The script you are interested to is in the onmenuclick attribute.
  3. After you have taken note of all required onmenuclick values just build you refresher as shown below.
@emiliano-poggi
emiliano-poggi / 0.md
Last active March 31, 2016 04:07
SharePoint 2013 how to CSS Image Sprites spcommon.png and custom

SharePoint 2013 how to CSS Image Sprites: spcommon.png and custom

SharePoint 2013 layouts come with a common image sprite called spcommon.png. We can access this image via CSS sprite with positioning or background technique and reuse standard layout icons in web pages.

The breakdown of css instructions for spcommon.png is documented here: http://ericoverfield.com/sharepoint-2013-spcommon-png-sprite-breakdown/

Basics:

  1. Build a custom CSS file using the image sprite technique
  2. Upload the custom CSS into the asset folder
@emiliano-poggi
emiliano-poggi / 0.md
Last active May 17, 2021 14:12
SharePoint 2013 How To Javascript Jquery Callout Manager

SharePoint 2013 How To Javascript Callout Manager

Callouts in SharePoint 2013 are now possible with minimal client side scripting thanks to the new callout.js framework. The fastest method is to embed the code into a code web part.

Useful MSDN starter topic: https://msdn.microsoft.com/en-us/library/office/dn135236%28v=office.15%29.aspx

In summary:

  1. Make sure to use SP.SOD.executeFunc to call your code when the callout framework has been loaded.
  2. Get an element as launchpoint from the document. If the element is dynamically created via javascript, a DOM get_element is necessary to correctly reference the launchpoint.
@emiliano-poggi
emiliano-poggi / 0.md
Last active August 29, 2015 14:15
SharePoint 2013 How To XSL Link Option List View Web Part

SharePoint 2013 How To XSL Link Option List View Web Part

XSL Link option allows to link an XSLT stylesheet uploaded to the site for processing and transforming List View data to which the web part is connetcted.

The input xml passed to XSLT is described here https://msdn.microsoft.com/en-us/library/office/ff602042(v=office.14).aspx

There are two main ways to work:

  • Just transform input data and render it as wanted
  • Include the default templates and override those as required