SHIFT-WIKI - Sjoerd Hooft's InFormation Technology
This WIKI is my personal documentation blog. Please enjoy it and feel free to reach out through blue sky if you have a question, remark, improvement or observation. See below for the latest additions, or use the search or tags to browse for content.
Powershell Remoting: Check Windows Patch Status
Summary: Goal of the script is to check the patch status for a Windows Server using PowerShell Remoting.
Date: Around 2022
Refactor: 6 April 2025: Checked links and formatting.
PowerShell: Calculate Free Space on NetApp Volumes
Summary: A script to calculate the free space on NetApp mvolumes using PowerShell.
Date: Around 2014
Refactor: 6 April 2025: Checked links and formatting.
This is a script to calculate the amount of free space on NetApp Volumes (which is nice if you have thin provisioned LUNs).
# Debug mode $debug = 0 if ($debug -eq "1"){Write-Host "DEBUG mode enabled!"; $ErrorActionPreference = "Stop"; Write-Host "On error: $ErrorActionPreference"} # Import DATA ONTAP Module Import-module D:\sjoerd\DataONTAP # Select Filer with default option provided $filer = Read-Host "Please enter the name of the filer you want to query [filer01]" if ($filer -eq ""){$filer = "filer01"} # Getting credentials for NetApp filer while ($filercredentials -eq $null) { Write-Host "Please provide authentication credentials for NetApp filer $filer" $filercredentials = $Host.UI.PromptForCredential("Please enter credentials", "Enter NetApp filer credentials", "root", "") } # Connect to Filer Connect-NaController $Filer -Credential $filercredentials | Out-Null # Create a hash table for clear view of the output $myTable = @() ForEach ($volume in (Get-NaVol)){ $SpaceInfo = "" | Select VolumeName,TotalSize,FreeSpace $SpaceInfo.VolumeName = $volume $totalsize = (Get-NaVol $volume).TotalSize $SpaceInfo.TotalSize = $totalsize / 1073741824 $leftoversize = $totalsize Write-Host "Calculating free space for volume $volume with a total size of $SpaceInfo.TotalSize GB." ForEach ($lun in (Get-NaLun | where {$_.Path -match "/$volume/"})){ if ($debug -eq "1"){Write-Host "Doing $lun now"} $lunsize = (Get-NaLun $lun).TotalSize $leftoversize = $leftoversize - $lunsize if ($debug -eq "1"){Write-Host "$volume with a total size of $totalsize has now $leftoversize space left"} } # Convert the amount of bytes left to gigabytes left and round it up to 2 decimals. $SpaceInfo.FreeSpace = [Math]::Round(($leftoversize / 1073741824),2) $myTable += $SpaceInfo } $myTable
Bash: Environment Script For Production and Acceptance
Summary: A small script to warn users about in which environment they have logged on to.
Date: 22 March 2011
Refactor: 6 April 2025: Checked links and formatting.
This is a script I use to warn users for the environment they work on. We have a lot of different environments and I like to take every opportunity to warn them about the environment, especially production. This is based on the hostname. I also use it to show a few specific thing, for example, where their system mails gets forwarded to. Below the script you'll find a section on how to set the script into action.
#!/bin/bash ######################################################################################################################## # Author : Sjoerd Hooft # Date Initial Version: 22 March 2011 # Comments: sjoerd_getshifting.com # # Description: # This is the script to warn about the environment where users login to. # # Recommendations: # The script is designed for a 120 column terminal. # # Changes: # Please comment on your changes to the script (your name and email address, line number, description): ######################################################################################################################## # Script Variables BOLD=`tput bold` BOLDOFF=`tput sgr0` ENV=`hostname -s | awk -F- '{ print $2 }'` MAIL=`cat $HOME/.forward` if [ $ENV == prd ]; then echo echo "You have logged on to the ${BOLD}PRODUCTION ENVIRONMENT${BOLDOFF}. Be careful." echo "You have logged on to the ${BOLD}PRODUCTION ENVIRONMENT${BOLDOFF}. Be very careful." echo echo "Your local mail is being forwarded to $MAIL" echo "If this is wrong please change it in $HOME/.forward" else echo "You have logged on to the Acceptance environment" fi exit
Script: Azure DevOps API: Remove Leases
Summary: Goal of the script is to remove all the leases that are set on all of the builds that are created with a specific pipeline.
Date: Around 2022
Refactor: 6 April 2025: Checked links and formatting.
Goal of the script is to remove all the leases that are set on all of the builds that are created with a specific pipeline:
- Retrieve the builddefinition id for the specified pipeline
- Lists all leases for the builddefinition
- Removes all the leases for the build definition id
If the leases kept you from deleting the build pipeline, you can delete the pipeline afterwards.