Category Archives: Scripting

Batch script to replace the hosts file with another

Used this batch script as part of a DR failover. I tried different powerShell and batch scripts to replace and add entries directly into the hosts file but most were giving me too many issues. The batch script below will … Continue reading &ra...

Posted in Microsoft, Scripting | Tagged | Leave a comment

PowerShell script – Join a server to a specific OU in Active Directory

A PowerShell script to add a server to a specific OU when joining a domain. If the script fails it will generate an error. The script will prompt for a username and password before it joins....

Posted in Microsoft, Scripting | Tagged | Leave a comment

Simple netsh script to assign Multiple IPs, DNS, Gateway, etc..

Batch script to assign static IP/DNS/Gateway/Subnet mask. Nothing fancy here but there is some syntax difference in adding a second dns “ip set vs ip add” etc. Pasting it here in case i need to reference it at some point....

Posted in Microsoft, Scripting | Tagged , | Leave a comment

Script to change the first 3 characters of a hostname – PowerShell

We were failing over a bunch of Windows Virtual machines to a new site and they all needed to be renamed to match their new location. The following script will rename the first 3 characters of the hostname from DC1 … Continue reading →...

Posted in Microsoft, Scripting | Tagged , | Leave a comment

WMI Command to remove a computer from an Active Directory Domain

I was working on a script for our DR test to remove a computer from a domain but without prompting for a username and password. Every other command I tried prompts for the admin credentials (I ran this on server … Continue reading →...

Posted in Microsoft, Scripting | Tagged , , , | Leave a comment

Uninstall software remotely with WMIC

Here is a very useful command that will silently uninstall a remote application and reboot if required (I ran this on 2012 R2 servers). Caution1: If you receive an error “Invalid node (discarded)” the command still lists software but it &...

Posted in Microsoft, Scripting | Tagged , , | Leave a comment

Running disk cleanup Remotely as a scheduled task

This only works up to server 2008 R2, Server 2012 no longer has the disk cleanup tool. Windows 2012 uses dism powershell tool to do a similar clean up. I was dealing with a server that was running out of … Continue reading →...

Posted in Microsoft, Scripting | Tagged , | Leave a comment

PowerShell create a simple dotted progress bar

I was looking to create a simple dotted progress bar in PowerShell. I needed something basic and simple similar to bash script progress bars. The below is exactly what I needed, its a timed for loop that creates six dots, … Continue reading &r...

Posted in Scripting | Tagged , , | Leave a comment

Troubleshoot a Windows server that randomly hangs

Here is a batch script that I found useful to identify which service or process was highly active just before a server froze up. On the server that I was troubleshooting the CPU would spike to a 100% and the … Continue reading →...

Posted in Microsoft, Scripting | Tagged , , , | Leave a comment

Script to capture a duplicate IP on your network

Here is a quick batch script to help identify a duplicate IP. When you run the “arp -a” command in the windows command prompt it will show you the IP address and the MAC address associated with the IP. When … Continue reading &rarr...

Posted in Scripting | Tagged | Leave a comment