Tag: script

Proxy Server Checker v1.0

This PowerShell script runs a basic test of functionality for a proxy server. It sets up a web request via a specified proxy server address, then retrieves the HTTP Response Code. If the code is returned as HTTP 200 OK, it'll add 200 to the final status code. At the end, it'll compare how many sites it was passed to how many OK responses it received to determine if the proxy server is functioning correctly.

I wrote this script to work with our monitoring system so that we could test the functionality of a proxy server. Passing it three sites to test and having it report OK if it received a 600 OK, WARN if 200 or 400, or go CRITICAL if 0. This proved to be a more reliable test than just a connectivity test, as the proxy server may be contactable, but not actually processing requests. This test proves that it is processing requests.

This script is compatible with Powershell 2 and above. I had originally written the script using some cleaner cmdlets, but the server we needed to run it on only had Powershell 2 and upgrading for this script was going to be more hassle than it was worth due to the server needing to be available at all times.

Usage: .\ProxyServerCheck.ps1

View / Download Script

RDP Connection Setter v1.0

Following on from my Windows XP & 7 guide, Enable RDP using the registry editor, I have created this PowerShell script to automate the task. This script will check if the "Remote Registry" service is started. If it isn't, it'll start it. It will then dig through the registry to find the DWORD we need to change and it'll switch it on/off depending on your parameters.

The registry keys are in the same location, so this PS1 should work for Windows XP & 7 target machines. I assume this means it will work for Windows Vista as well, and probably 8, 8.1 and 10 as well, but these are all untested.

Usage: .\SetRDP.ps1 -PC computername [ -enable | -disable ]

View / Download Script

Network Scanner v1.0

This PowerShell script is a network scanner. Utilising the Invoke-PingSweep function, it will attempt to ping each host in the specified range and if it gets a response, it will attempt to find open ports from a specified list.

The Invoke-PingSweep function is available from the TechNet gallery and I take no credit for writing this integral part of the script. https://gallery.technet.microsoft.com/scriptcenter/Invoke-TSPingSweep-b71f1b9b

This script will then output a list of discovered IP addresses, hostnames and open ports. There are options to then export to a CSV and/or TXT file as well.

Usage: .\NetScan.ps1 -StartIP -EndIP [-CSV file.csv] [-TXT file.txt] [-CSVHostsOnly] [-TXTHostsOnly]

View / Download Script

Find/Replace Script v1.0

This PowerShell script is a simple find/replace tool, much like the ones you find inside your favourite text editors. Unlike most text editors, however, this will run against all files of a certain extension within a specified folder. This enables you to edit, say for example, every CSV file in folder C:\LotsofCSVfiles.

I wrote this script as I had a large number of CSV files that I needed the same find/replace function performed on all files. Rather than opening 100+ CSV files and running a find/replace one-by-one, I could simply tell this script to search for all files in the folder and do the find/replace.

By default, the script looks for CSV files, but using the -Ext parameter, you can select a different file extension. As the standard functions work via regular expressions, I have also added a line to escape any characters to prevent failures.

Usage: .\FindReplace.ps1 -Path C:\folder\path -String "findme" -Replace "replaceme" [-Ext txt]

View / Download Script

CSV Tool: Remove Last Line v1.1

This PowerShell script is part of a group of CSV Tools I have written. The script is a simple one that simply removes the last line of an inputted CSV file. It can obtain the CSV file either by being directly passed the name of a CSV file, by being given a text file list or finally by searching a directory for all CSV files.» Continue reading...

Running Man v1.0

This script is just a bit of silliness I made while bored one afternoon. It does nothing interesting other than make a stickman run backwards and forwards in a PowerShell window. View / Download Script

Mass NTFS Compression Tool – Status Check v1.1


You will hopefully have seen my Mass NTFS Compression Tool in the scripts section. From version v1.4 of this script, there is a function to add a status check. The idea behind this is that you can have multiple copies of the Mass NTFS Compression Tool running and use this script to monitor the status of all scripts.» Continue reading...

Idera Up.Time Agent Password Setter v1.1


This PowerShell script is specific to a piece of software called Idera Up.Time Infrastructure Monitor. We have recently started using this great monitoring application, but I found some parts of rolling it out across our infrastructure a little bit tedious or prone to human error. One such part being setting the up.time agent’s password.» Continue reading...

Mass NTFS Compression Tool v1.5


This PowerShell tool allows you to apply NTFS compression on mass with full visibility of what files are being compressed. The tool runs from a CSV file with at least two columns, “Name” and “Path”. This essentially matches a report exported from Treesize.

Once the script is launched, a progress bar will be displayed at the top of the screen showing how far through the CSV file the script has run, giving an indication of how many files are left to compress.» Continue reading...

Scripts Section

As you may or may not know, I work in the IT sector, specifically as a Production Support analyst dealing with server & application support.

I am not a big fan of mundane and tedious tasks, who is? We've had a lot of talk about PowerShell in the office recently, but very few people seem to understand what it is, how to use it, or have the patience to learn any sort of scripting, so I've taken this as a great opportunity to get myself involved and learn this great language.

As I write new scripts, any that I feel would be useful to others, more so those that are not specific to my environment, I will be sharing them online, so I have created a scripts section here. Any scripts I upload are free to use and by all means feel free to ask questions and critique my scripts. I am only just starting out in the world of PowerShell, so I expect my scripts won't be perfect or as tidy as they could be. I'm always happy to help others out and appreciate it when people critique my work as it helps me better my skills.

The first script I have uploaded is my Local Administrator Tool v1.0. This is a script I have written as I have found myself in a position where I have a service account that must be a local administrator on around 400 servers. I don't particularly fancy logging onto 400 servers and manually granting this account local administrator rights, so I've created a script that I can just pass a username (or a list of users) and a list of servers (or just the one server if I fancied). It'll then go off and, so long as the account running it has the permissions to do so, grant the local administrator rights to the specified account. Many hours saved! Hooray!