Skip to content

Instantly share code, notes, and snippets.

#Requires -Modules IsamsBatchApi
$config = Get-Content ./config.json -Raw | ConvertFrom-Json
$clientID = $config.BatchAPI.ClientID | ConvertTo-SecureString | ConvertFrom-SecureString -AsPlainText
$clientSecret = $config.BatchAPI.ClientSecret | ConvertTo-SecureString | ConvertFrom-SecureString -AsPlainText
$isamsInstance = $config.BatchAPI.Host | ConvertTo-SecureString | ConvertFrom-SecureString -AsPlainText
$searchBase = $config.ActiveDirectory.PupilSearchBase | ConvertTo-SecureString | ConvertFrom-SecureString -AsPlainText
$removeExcess = $false
$count = $sets.Count
$i = 0
foreach($set in $filteredSets){
$percent = $i * 100 / $count
$i += 1
$teamName = $set.SetCode + " " + $year
Write-Progress -Activity "Creating Team" -Status "$percent% Complete | working on $teamName)" -PercentComplete $percent
$ProgressPreference = "SilentlyContinue"
@CraigChamberlain
CraigChamberlain / HttpLogger
Last active November 10, 2021 21:08
Makes
while($true){
$timeStamp = (Get-Date).toString('yyyy-MM-dd-HH-mm-ss')
$path = $pwd.Path + "\" + $timeStamp + ".txt"
Start-Job{
try{
Invoke-WebRequest https://www.dundasparksgolf.co.uk/ > $null
"Success`t"+$using:timeStamp
} catch
{
$error[0] > $using:path
@CraigChamberlain
CraigChamberlain / Join-CovidDataOnPostCode.ps1
Last active December 23, 2020 20:42
Example use of Get-CovidProtectionLevelFromPostCode.ps1
$data = Import-Csv "PupilsByPrimaryAddress.csv"
$uniqueUkPostCode = $data |? {$_.txtCountry -eq "United Kingdom"} |% {$_.txtPostCode} | Sort-Object -Unique |? {$_ -ne ''}
$uniqueUkPostCode |
ForEach-Object -Begin {
$total = $uniqueUkPostCode.count
$i = 0
$dict = @{}
} -Process {
@CraigChamberlain
CraigChamberlain / Get-CovidProtectionLevelFromPostCode.ps1
Last active January 8, 2021 09:10
Get UK Covid Protection Level From Post Code
param(
[ValidatePattern(" *[a-zA-z0-9]{2,4} +[a-zA-z0-9]{2,4} *")]
[Parameter(Position = 0, Mandatory = $true)]
[string]$postCode
)
BEGIN
{
$root = "https://coronavirus.data.gov.uk/search?postcode="
}
PROCESS{
@CraigChamberlain
CraigChamberlain / github_redirects.ps1
Last active February 9, 2024 10:04
Make a canonical copy of your GitHub pages site at another domain or subdomain.
$newDomain = "yourdomain.com"
$outputDir = "_redirects"
function redirectPage($uri) {@"
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting to https://$newDomain$uri</title>
<meta http-equiv="refresh" content="0; URL=https://$newDomain$uri">