Skip to content

Instantly share code, notes, and snippets.

View nonprofittechy's full-sized avatar

Quinten Steenhuis nonprofittechy

View GitHub Profile
@nonprofittechy
nonprofittechy / gist:1f8123f79166241575fa
Last active August 29, 2015 14:02
Bulk-Import photos into AD
$ipath = "C:\PATH_TO_THUMBNAILS"
$images = gci -Path $ipath
$jpgBytes = $null
foreach ($image in $images) {
$jpgBytes = $null
$jpgBytes = [byte[]]$jpg = Get-Content ($image.fullName) -encoding byte
@nonprofittechy
nonprofittechy / disconnect-wsession.psm1
Created September 19, 2016 20:47
disconnect-wsession.psm1
<#
Disconnect-wsession: forefully logoff a user's session using the qwinsta.exe / rwinsta.exe commands
Purpose: prevent automatic account lockout
Defaults to logging off the current user's session on the remote computer.
#>
function disconnect-wsession ($computer, $username) {
$username = if ($username) {$username} else {$env:username}
if (test-connection $computer -count 1) {
<#
Removes the specified Sharepoint Lists from Outlook.
Uses Outlook MAPI and must run on each user's workstation. Deploy as a script with GPO or System Center
Author: Quinten Steenhuis, 9/26/2016
#>
<#
# Uncomment this section and update with your own lists to remove. If left
# unspecified, this script will rely on the default list set via GPO for SP 2013
# Please note you'll need to update the GPO before next refresh cycle if relying on
<#
.SYNOPSIS
Generates the STSSyncURLs for a Sharepoint Online Site using CSOM. Should be run from a SharePoint server.
TODO: identify which DLL contains the microsoft.sharepoint.utilities.spencode method to allow running without a SharePoint install.
.DESCRIPTION
This script is useful for generating a long list of STSSYNC urls without tediously connecting dozens of lists to Outlook, sharing them, and extracting
the URL in that fashion. The output is a PSOBject which can be piped to a CSV for further manipulation, or to a separate script that creates appropriate GPOs
or .REG files for further automation.
Requires load-csomproperties.ps1 from: https://gist.github.com/glapointe/cc75574a1d4a225f401b
.EXAMPLE
<#
.SYNOPSIS
Updates lists with "Contacts" in the name, replacing any empty "Last Name" fields
with the company name, to prepare for migration to SharePoint Online.
Syntax: fix_missing_lastname.ps1 -url "https://my.sharepoint.site" or update parameter below
.DESCRIPTION
Will scan one-level deep for sub-sites that have a list with 'Contacts' in the title.
.NOTES
<#
.SYNOPSIS
Create GPOs that set the Administrative Template for "Default SharePoint Lists" as specified in a CSV.
The CSV can update (or create) multiple GPOs based on the column "gpoName".
.DESCRIPTION
The input CSV has 5 mandatory columns:
gpoName : Name of the GPO to update
ou : the name of the OU to link the GPO to
siteName : Site name on Sharepoint
@nonprofittechy
nonprofittechy / code.gs
Last active January 21, 2018 09:47
snippet from code.gs - WriteClearly Google Docs Add On
/**
* Return a single score for the selected text
* @param {string} text text to evaluate, can include HTML elements
* @return {object} object -- has the index (score) and a list of suggestions
*/
function getTextEvaluation() {
var selection = DocumentApp.getActiveDocument().getSelection();
if(selection) {
var textArray = getSelectedText();
} else {
function runEvaluation() {
console.log("before disabled");
this.disabled = true;
console.log("after disabled");
$('#error').remove();
var origin = $('input[name=origin]:checked').val();
var dest = $('input[name=dest]:checked').val();
var savePrefs = $('#save-prefs').is(':checked');
google.script.run
.withSuccessHandler(
Copy-Item -Path $PSScriptRoot'\LayoutModification.xml' -Destination $env:SystemDrive'\Users\Default\AppData\Local\Microsoft\Windows\Shell'
Copy-Item -Path $PSScriptRoot'\Internet Explorer.lnk' -Destination $env:SystemDrive'\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories'
$numLen = 7
$prefix= "GBLS-"
$ComputerModel = (Get-WmiObject -Class Win32_ComputerSystem | Select-Object Model).Model
$SerialNumber = (Get-WmiObject -Class Win32_BIOS | Select-Object SerialNumber).SerialNumber
if ($serialNumber.length -ge 7) {
$shortSerial = $serialNumber.substring($serialNumber.length - $numLen,$numLen)
} else {
$shortSerial = $serialNumber
}