Skip to content

Instantly share code, notes, and snippets.

View sweeneyrobb's full-sized avatar

Robert Sweeney sweeneyrobb

View GitHub Profile
@sweeneyrobb
sweeneyrobb / mass-update-office-365-upns.ps1
Created January 8, 2018 19:25
A PowerShell script that will mass assign UPNs for users in previous domain.
$oldSuffix = "old-domain.com"
$newSuffix = "new-domain.com"
Get-MsolUser |
Where-Object { $_.UserPrincipalName.EndsWith($oldSuffix) } |
ForEach-Object {
Set-MsolUserPrincipalName -ObjectId $_.ObjectID -NewUserPrincipalName ($_.UserPrincipalName.Replace($oldSuffix, $newSuffix))
}
@sweeneyrobb
sweeneyrobb / app-routes.ts
Last active June 24, 2016 18:57
Angular 2 Router Example
import { ContactsListComponent } from './contacts-list.component';
import { ContactsDetailComponent } from './contacts-detail.component';
import { WelcomeComponent } from './welcome.component';
export const AppRoutes = [
{
name: "Welcome",
description: "Welcome to the Contacts Application.",
path: '',
showInNav: true,
@sweeneyrobb
sweeneyrobb / Start-ExecuteUAC.ps1
Last active February 1, 2016 19:43 — forked from yangyer/Start-ExecuteUAC.ps1
Powershell sudo
function Start-ElevatedUACSession {
$outputFiles = @{
Standard = [System.IO.Path]::GetTempFileName();
Error = [System.IO.Path]::GetTempFileName();
}
$cmd = [string]::Join(" ", $args)
Write-Host "Executing Elevated: $cmd"
Start-Process powershell -Verb "runAs" -WindowStyle Hidden -Wait -ArgumentList "/Command ""& { $cmd > '$($outputFiles.Standard)' }"""
Get-Content $outputFiles.Standard
$outputFiles.Values | Remove-Item
@sweeneyrobb
sweeneyrobb / move-ef-to-bin.bat
Last active January 28, 2016 02:47
used as a reminder on how to run Update-Database using migrate.exe in emegency scenarios...like today.
copy ..\packages\EntityFramework.6.1.0\tools\migrate.exe .\bin\
cd .\bin
migrate {assembly} /startUpConfigurationFile=..\web.config
@sweeneyrobb
sweeneyrobb / replace-prompt.ps1
Created January 2, 2016 19:23
Tweaks the prompt so that when your working directory appears in the $prompts hash table it will replace it with a designated string (the value of the hash table). Makes working with long paths a little bit more bearable without reducing the path too much. Add to $PROFILE to use without pasting every time.
function prompt() {
$prompts = @{
$HOME = "~";
"$HOME\Documents\GitHub" = "~\[github]";
$env:windir = "windir";
}
$loc = (Get-Location | Select -ExpandProperty Path)
$prompts.GetEnumerator() | ForEach-Object { $loc = $loc.Replace($_.Name, $_.Value) }
@sweeneyrobb
sweeneyrobb / export-wsp.ps1
Created January 1, 2016 00:53
This script will export a WSP from the Configuration Database. Handy if you do not have access to the binaries during a migration.
$wspFile = "solution.wsp"
$outDir = "c:\temp"
$farm = Get-SPFarm
$wsp = $farm.Solutions.Item($wspFile).SolutionFile
$outFile = Join-Path -Path $outDir -ChildPath $wspFile
$wsp.SaveAs($outFile)
@sweeneyrobb
sweeneyrobb / install-jekyll-prerequisites.ps1
Last active June 28, 2018 00:23
This PowerShell script will install and configure all the pre-requisites for Jekyll. There is commented code to initalize a Jekyll directory. Simply change directory to desired folder, uncomment script, and execute.
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
choco install ruby -y
choco install ruby2.devkit -y
$env:PATH = [System.Environment]::GetEnvironmentVariable("PATH", "Machine")
$env:Path += ";$env:ChocolateyBinRoot\ruby23\bin"
cd "$($env:ChocolateyInstall)\helpers\functions"
@sweeneyrobb
sweeneyrobb / clicky.html
Created November 28, 2015 19:53
A Jekyll include file for integrating a site with clicky.com. Enjoy!
<script type="text/javascript">
var clicky_site_ids = clicky_site_ids || [];
clicky_site_ids.push({{ include.trackingid }});
(function() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//static.getclicky.com/js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(s);
})();
@sweeneyrobb
sweeneyrobb / Get-WebFiles.ps1
Created July 10, 2015 21:05
Download a list of files to output directory. Current out directory is set to current working directory.
$outDir = "."
@(
"http://domain/images/image1.jpg",
"http://domain/images/image2.jpg",
"http://domain/images/image3.jpg",
"http://domain/images/image4.jpg",
"http://domain/images/image5.jpg",
"http://domain/images/image6.jpg",
@sweeneyrobb
sweeneyrobb / jekyll-boilerplate.ps1
Created July 1, 2015 20:02
Creating a boilerplate Jekyll directory.
$folders = @("_drafts", "_includes", "_layouts", "_posts", "_data")
$folders | %{ New-Item -Name $_ -ItemType Directory }
$files = @("_config.yml")
$files | %{ New-Item -Name $_ -ItemType File }