Skip to content

Instantly share code, notes, and snippets.

View cjvandyk's full-sized avatar

Cornelius J. van Dyk cjvandyk

View GitHub Profile
@cjvandyk
cjvandyk / Update-SPSiteUrl.ps1
Created April 27, 2017 13:20
This script updates the given site URL to the given new site URL.
[CmdletBinding()]
Param ([Parameter(Mandatory=$true, HelpMessage="Current site URL?")][ValidateNotNullOrEmpty()][string]$oldUrl,
[Parameter(Mandatory=$true, HelpMessage="Desired new site URL?")][ValidateNotNullOrEmpty()][string]$newUrl)
$validate = Get-SPSite $newUrl;
if ($validate -eq $null)
{
try
{
$site = Get-SPSite $oldUrl;
$site.Rename($newUrl);
@cjvandyk
cjvandyk / Powershell-Remove-item-from-array.ps1
Created March 14, 2017 17:16
Powershell-Remove-item-from-array-desc
$list = @(); #Initialize the array.
$list += "Apple"; #$list = "Apple"
$list += "Orange"; #$list = "Apple", "Orange"
$list += "Tomato"; #$list = "Apple", "Orange", "Tomato"
$list += "Grape"; #$list = "Apple", "Orange", "Tomato", "Grape"
$list -= "Tomato"; # ERROR!!! You can't do this!
#but this works
$list = $list -ne "Tomato"; #$list = "Apple", "Orange", "Grape"
@cjvandyk
cjvandyk / Powershell-Remove-duplicates-from-array.ps1
Created March 14, 2017 17:00
Powershell-Remove-duplicates-from-array-desc
$array = @("a", "b", "c", "b", "d", "a"); #Setup the array.
$array = $array | sort -unique; #Sort the array while using only unique values.
@cjvandyk
cjvandyk / TSQL-Select-no-duplicates.sql
Created March 14, 2017 16:48
TSQL-Select-with-no-duplicates.
SELECT *
FROM tblSites
GROUP BY Url
HAVING count(Url) = 1;