Skip to content

Instantly share code, notes, and snippets.

View PartTimeLegend's full-sized avatar

Antony Bailey PartTimeLegend

View GitHub Profile
@PartTimeLegend
PartTimeLegend / OutOfDateNuget.ps1
Created June 2, 2021 09:56
OutOfDateNuget.ps1
dotnet tool update --global dotnet-outdated-tool
$errorCount = 0
Get-ChildItem -Path .\ -Filter *.csproj -Recurse -File -Name| ForEach-Object {
[System.IO.Path]::GetFileNameWithoutExtension($_)
dotnet outdated $_ -f -inc CB. -u
if ($LASTEXITCODE -ne 0)
{
$errorCount++
}
}
variable "az_region" {
type = string
default = "UK South"
}
variable "az_region_abbr_map" {
type = map(any)
description = "Map is used to obtain 3 letter azure region abreviation for naming resources"
default = {
"Central US" = "cus"
"East US 2" = "eus2"
@PartTimeLegend
PartTimeLegend / breaklease.ps1
Last active April 14, 2021 13:49
Break Lease on File in Azure Blob Storage
$blobName = ""
$resourceGroup = ""
$storageAccount = ""
$container = ""
$context = (Get-AzStorageAccount -ResourceGroupName $resourceGroup -AccountName $storageAccount).Context
$blob = (Get-AzStorageBlob -Context $context -Container $container -Blob $blobName)
$leaseStatus = $blob.ICloudBlob.Properties.LeaseStatus;
switch ($leaseStatus)
{
"Locked"
@PartTimeLegend
PartTimeLegend / Get-AzVMStatus.ps1
Created April 7, 2021 14:49
Determine a Azure VM running status
function Get-AzVMStatus
{
param(
[Parameter(Mandatory=$true)][string]$resourceGroup,
[Parameter(Mandatory=$true)][string]$vmName,
)
return (Get-AzVM -ResourceGroupName $resourceGroup -Name $vmName -Status).Statuses[1].DisplayStatus
}
$registry = "myRegistry"
$keep = 5
$prAgo = "7d"
$masterAgo = "90d"
$prCron = "0 0 * * *"
$masterCron = "0 0 * * *"
$repositories = @("foo.bar",
"bar.foo",
"foobar.boofoo",
"barfoo.foobar"
@PartTimeLegend
PartTimeLegend / FindWindowsEdition.ps1
Created March 25, 2021 09:35
Find Windows Edition
switch ((Get-WmiObject -class Win32_OperatingSystem).Caption)
{
{$_.Contains("Home")} { Write-Output "Home" }
{$_.Contains("Business")} { Write-Output "Business" }
{$_.Contains("Enterprise")} { Write-Output "Enterprise" }
Default { "Unknown" }
}
@PartTimeLegend
PartTimeLegend / backup.sh
Created March 1, 2021 10:34
Backup dir to git
#!/usr/bin/env bash
cd /config
git status
git add .
dt=$(date '+%d/%m/%Y %H:%M:%S');
git commit -m "$dt"
git push origin master
@PartTimeLegend
PartTimeLegend / GenerateAlphanumberPassword.ps1
Created February 22, 2021 18:22
Generate Alphanumeric Password in Powershell
$length = 10
Write-Output (-Join ((65..90) + (97..122) | Get-Random -Count $length | % {[char]$_}))
@PartTimeLegend
PartTimeLegend / gitmastertocableselect.sh
Last active February 16, 2021 17:16
Change Git Branch master to cableselect
#!/usr/bin/env bash
# I think I'm funny.
git checkout master
git branch -m cableselect
git push origin -u cableselect
git push origin --delete master
@PartTimeLegend
PartTimeLegend / KillWindowsDefender.ps1
Last active June 3, 2021 08:49
Windows Defender Remover
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs;
exit
}
Write-Output "Disabling Windows Defender"
Set-MpPreference -DisableRealtimeMonitoring $true
Write-Output "Uninstalling Windows Defender"
Uninstall-WindowsFeature -Name Windows-Defender
Write-Output "Preventing future installation of Windows Defender"