Posts

Showing posts with the label Powershell

Decaf caffeine: Keeping Your PC Awake with PowerShell

Image
If you’re like me and find yourself working odd hours—especially over the weekend—you know how frustrating it can be when your PC decides to take a nap every few minutes. I often need to glance at my screen to check logs, monitor tasks, or respond to messages, and having to log back in every five minutes is a productivity killer. That’s why I built a simple PowerShell script that acts as a native replacement for the popular Caffeine software. For those unfamiliar, Caffeine is a lightweight utility that simulates a keypress to keep your machine awake. It’s handy—but many corporate environments block third-party utilities like it, leaving you stuck with default sleep settings. Why PowerShell? PowerShell is built into Windows, making it a perfect candidate for scripting solutions that bypass third-party restrictions. My script uses a loop to simulate activity at regular intervals, preventing the system from locking or going to sleep. No installs, no admin rights, no fuss. Here’s a simplif...

Create multiple Azure files shares using Powershell

Image
If you have to create multiple shares for an Azure files instance as part of a migration or new deployment it can be very time consuming. This script has been moved to GitHub, link below:

Apply tags to azure resource groups from csv file

Image
This script is used to apply tags as per a csv file. Tags will be applied in uppercase. If a resource group is present in the csv but not in Azure it will be skipped. A log file will be generated in the log folder. A backup of the resource groups previous tags and values will be created in the backup folder. This script has been moved to GitHub, link below:

List object contributors in all Azure subscriptions with Powershell

Image
The below script will loop through all Azure subscriptions excluding Visual Studio subscriptions, it will then look at every object and list/export everyone who has a role that has the word "Contributor" in it. This script has been moved to GitHub, link below: Example below:

List printers and IP addresses on a windows server using Powershell

Image
  This script has been moved to GitHub, link below:

Stop and disable a Windows service using powershell

Image
Populate "computers.txt" with all the server names you wish this to run on then adjust the script to fit the service you require. This script has been moved to GitHub, link below:

Split file every xxx lines with Powershell

Image
I recently ran in to an issue whilst using CommVault to restore some archive files from it's HSM. You have to run the gxhsmutility to scan the files to check if any stub files remain, if there is it outputs what is called a map file, you then run the restore again pointing to said map file. The problem with this was that if the map file was over 100,000 lines the recovery would just crash, so I wrote this to split the map file out in to multiple map files I could then use to recover the data. This script has been moved to GitHub, link below:

Add random number prefix to filename with Powershell

Image
This allows you to add a randomly generated number to the prefix of a bunch of files. In the below example we are adding a random prefix to every *.jpg file. This script has been moved to GitHub, link below:

Create html galleries of images & videos using Powershell

Image
 This script is designed to be placed in a folder with lots of images and videos including subfolders, create thumbnails of all the images found and uses ffmpeg to create frame sheets for movies then add 100 per HTML page with a "Next" link at the bottom linking to the next gallery page. This script has been moved to GitHub, link below:

Check if multiple nics are set to register with DNS

Image
  This checks all the nics on a server to see if multiple nics have the "Register this in DNS" which if multiple are selected it can cause connectivity issues. This script has been moved to GitHub, link below: Example output: server01 - 10.10.10.10 - True server01 - 192.168.0.1 - False server02 - 10.10.10.20 - True server03 - 10.16.10.30 - True

Powershell Unable to find module repositories

  When running: Get-PSRepository in Powershell and you get the error: WARNING: Unable to find module repositories. This is normally because you are behind a poxy and you need to set the proxy settings for Powershell, to do this follow these steps: Run notepad $PROFILE Notepad will open and probably tell you the file is not present and would you like to create it, select yes and enter the following in the file, obviously changing the proxy and port to your proxy and port: [system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy('http://YOURPROXY:8080') [system.net.webrequest]::defaultwebproxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials [system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true Save and exit the file Close and re open Powershell Run Register-PSRepository -Default This should now allow you to register the repos.