Skip to content

Instantly share code, notes, and snippets.

View wictorwilen's full-sized avatar
😀

Wictor Wilén wictorwilen

😀
View GitHub Profile
@wictorwilen
wictorwilen / MyInterestingDocuments.html
Last active August 29, 2015 14:15
Office Graph Examples
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.1.js"></script>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/knockout/knockout-3.1.0.js"></script>
<script type="text/javascript" src="../Scripts/MyInterestingDocuments.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js"></script>
<script type="text/javascript">
Type.registerNamespace('Wictor.OfficeGraph.JS')
Wictor.OfficeGraph.Document = function (id, title) {
var self = this
@wictorwilen
wictorwilen / AppOnly-ACS-PowerShell-Sample.ps1
Last active April 21, 2024 09:04
SharePoint Online: App Only policy PowerShell tasks with ACS
# For more information see: http://www.wictorwilen.se/sharepoint-online-app-only-policy-powershell-tasks-with-acs
$clientId = "<INSERT YOUR CLIENT ID HERE>"
$secret = "<INSERT YOUR CLIENT SECRET HERE>";
$redirecturi = "<INSERT YOUR REDIRECT URI HERE>"
$url = "https://<TENANT>.sharepoint.com/sites/contoso/"
$domain = "<TENANT>.sharepoint.com"
$identifier = "00000003-0000-0ff1-ce00-000000000000"
@wictorwilen
wictorwilen / metadataproperties.js
Created March 10, 2015 11:44
Custom metadata properties using JSOM
$.getScript(_spPageContextInfo.webServerRelativeUrl + "/_layouts/15/" + "SP.Taxonomy.js", function () {
var context = SP.ClientContext.get_current()
var session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
var term = session.getTerm('beeda2c0-d3d1-4ceb-90f8-99c74ad86659');
context.load(session);
context.load(term);
context.executeQueryAsync(
function () {
var t = "Name: " + term.get_name() + "\n"
@wictorwilen
wictorwilen / EnumWebProps.js
Created March 12, 2015 09:53
Enumerate SPWeb properties in JSOM
var context = SP.ClientContext.get_current()
var web = context.get_web()
var props = web.get_allProperties()
context.load(web)
context.load(props)
context.executeQueryAsync(
function () {
var t = "Properties\n"
for (var z in props.get_fieldValues()) {
@wictorwilen
wictorwilen / EmptyList.ps1
Created March 19, 2015 12:19
Remove items from a list in SPO
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext(SITE)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username,$password )
$web = $ctx.Web
$ctx.Load($web)
$list = $web.GetList(LISTURL)
$ctx.Load($list)
$ctx.ExecuteQuery()
# Fiddle a bit with $batch and $c (could be done better, but it worked for my needs right now)
@wictorwilen
wictorwilen / ConnectToAzureFiles.cmd
Created April 28, 2015 07:18
Connect to Azure Files
net use z: \\<account name>.file.core.windows.net\<share name> /u:<account name> <account key>
@wictorwilen
wictorwilen / RemoveSiteCollectionsfromRecycleBininSharePointOnline.ps1
Created April 28, 2015 14:43
Remove Site Collections from Recycle Bin in SharePoint Online
Import-Module Microsoft.Online.SharePoint.PowerShell
$tenant = "<tenant>"
$password = "<password>"
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext("https://$tenant-admin.sharepoint.com")
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("admin@$tenant.onmicrosoft.com",(ConvertTo-SecureString "$password" -AsPlainText -Force ))
$tenant = New-Object "Microsoft.Online.SharePoint.TenantAdministration.Tenant" -ArgumentList $ctx
$tenant.RemoveDeletedSite("https://$tenant.sharepoint.com/teams/<SITE>")
@wictorwilen
wictorwilen / updatetimezone.js
Created May 25, 2015 08:32
Update TimeZone using JSOM
var context = SP.ClientContext.get_current()
var web = context.get_web()
var rs = web.get_regionalSettings()
var tz = web.get_regionalSettings().get_timeZone()
var tzs = web.get_regionalSettings().get_timeZones()
context.load(web)
context.load(rs)
context.load(tz)
context.load(tzs)
context.executeQueryAsync(
@wictorwilen
wictorwilen / ListCustomActions.js
Created July 15, 2015 12:45
List Custom Actions using JSOM
var context = SP.ClientContext.get_current()
var web = context.get_web()
var actions = web.get_userCustomActions();
context.load(actions)
context.executeQueryAsync(
function () {
console.log('Success')
var enumerator = actions.getEnumerator();
while (enumerator.moveNext()) {
@wictorwilen
wictorwilen / AddCustomAction.js
Created July 15, 2015 12:56
Add Custom Action using JSOM
var context = SP.ClientContext.get_current()
var web = context.get_web()
var actions = web.get_userCustomActions();
context.load(web)
context.load(actions)
context.executeQueryAsync(
function () {
var newAction = actions.add();