Hackviking He killed Chuck Norris, he ruled dancing so he took up a new hobby…

8Jan/180

Powershell: IIS Application Pool Killer

Every now and then IIS application pools lock up and needs to be killed. You can add the field PID in Task Manager and then use cmd tools to find which one of the IIS Worker Process is the right one and kill it. I created a simple script that lists all the IIS Application Pools by name, select the one you need to kill and the script kills it. The script is available on my Github and is named IISAppPoolKiller.ps1. Please comment below what you have been using this for!

Continue reading...

5Jan/180

Powershell: Pending Windows Updates

Every now and then you need to check if your servers or client computers have pending updates. You can generate a simple list of this with Powershell. I have created a script for this on my Github named ListPendingWindowsUpdates.ps1. Here is a quick breakdown of the script, feel free to use and modify it anyway you like. Please comment below what you ended up doing with it.

We always need to declare the functions of the Powershell script first but I will dig into the only function of this script below and start with the locally executed code. This script have one locally executed part and then a function that is executed on each and every server/client it lists. For this to work you need to run the script with domain admin rights. Both to access the Active Directory and to remote execute the code on each server/client.

Continue reading...

4Jan/180

Powershell: Manage folder permissions

Working with folder and share security is to often treated as set and forget. A good practice is to run daily jobs to check, report and reset permissions on shared folders and home directories. There are several ways to do this but it can easily be done from Powershell. This can also be used when migrating between servers and access needs to be added or removed. Here is a few useful code snippets when working with folder access and shares in Powershell.

Continue reading...

3Jan/180

New Relic Wallboard

New Relic is a very good tool to monitor you servers and applications with a bunch of metrics och features. If you landed on this page you probably already use it so I want go into any more details on it. There are things I love about it and things I hate about it, the way it is with most tools you come across in your day to day work.

For monitoring we use the Health Map filtered to Hosts and related applications which gives us a great overview of the overall condition of the servers and the web applications running on them. Currently there is no customization for the sorting or the layout and no kiosk mode for a proper wallboard. When building a good wallboard for your support or NOC you want to add additional information and be conservative with the real estate, you want to fit all the information on one big screen so you get all the information you need in one glance. This is where New Relic doesn't deliver as good as it does on other parts.

Continue reading...

2Jan/180

Jira Service Desk: E-mail attachments blocked on re-open

After using Jira Service Desk for a while we ran into a problem with automatic re-opening tickets when a customer replied to a closed ticket. The automatic re-open worked fine but any attachments where just thrown away. Usually customers respond back with a screenshots, logs or similar information needed to further investigate the ticket.

At the end of the comment that triggered the re-open and contained an attachment the following error message was added: Failed to add the following attachment to this issue because file attachments are disabled for the system.

Did a lot of research online without finding any solution, a lot of people had the problem but no suggested solutions. After some testing I realized that when the e-mail gets ingested by Jira Service Desk the contents of the e-mail is added as a comment and any attachments to the e-mail is attached to the case. After this occurs the ticket is automatically re-opened due to the customer comment. A closed or resolved ticket can not get new attachments and since Jira Service Desk is trying to attach the file before the ticket is re-opened it fails.

The simple solution to this is to add a property on the Closed workflow step for the Jira Service Desk project. If you edit your workflow and click the Closed step then open up the Properties, here you can add a new property key jira.issue.editable with the value true. This will allow closed issues to be edited which will make sure that the attachments are added during the re-open process. The only drawback with this is the Edit button being visible on closed cases.

17Dec/170

Powershell: Manage IIS SMTP server

Setting up Microsoft Internet Information Services (IIS) SMTP service is pretty straight forward for simple implementations. It hasn't really keept up with time and I'm pretty sure not to many people use it anymore. Working with an older implementation in a system that used distributed SMTP on each and every IIS server I realized we needed to centralize it so we could secure it properly. This included re configuring an old IIS SMTP server and then add a bunch of aliases to make sure the server accepted all the incoming e-mails.

Continue reading...

11Sep/170

MS SQL: Automatically restore latest backup

A common need is to restore the latest production backup to a test system or user acceptance test system on a regular basis. Depending on your system (database) size this can be time consuming. You would prefer to have this done during the night right after the backups run. If you don't have any third party solution for backups where this feature is built in it can be a bit tricky. The reason why is that the automated backups in a Microsoft SQL Server maintenance plan have somewhat unpredictable names.

Solution to this problem is a simple T-SQL script that you can put in a maintenance plan, to run every night or just on schedule as you please. The script grabs the latest backup an makes the restore.

The script can be downloaded from Github - T-SQL Automatic restore of latest backup

Continue reading...

24Aug/160

Reset Windows 10 password

Upgraded one of my laptops to Windows 10 and immediately locked the admin account. Googled and found a bunch of suggestions using the Windows 10 install CD? As most other people I upgraded via the Windows 10 upgrade notice that was bugging me for months. So how do you get back into a Windows 10 machine you locked your self out of?

Before the upgrade I decrypted my boot disk and uninstalled the old Truecrypt install I had on there so accessing the disk wasn't an issue. If you have full disk encryption enabled you will not be able to use this method.

Prepair Hiren's BootCD & Boot

Hiren's BootCD contains a miniXP version that is perfect for this. Download it and follow the instructions in Launching Hiren's BootCD from USB Flash Drive. They have a really good step by step guide there. Once that is all done restart your computer from the USB drive and select "Mini Windows XP".

Prepare for password reset

Once you are booted up locate your windows boot drive. In this example I will use E:\ as the Windows boot drive. Locate the following file:

E:\Windows\System32\utilman.exe

Rename it to:

E:\Windows\System32\utilman.exe.bak

Then make a copy of:

E:\Windows\System32\cmd.exe

And rename it to:

E:\Windows\System32\utilman.exe

You can also do this via the command prompt like this:

move d:\windows\system32\utilman.exe d:\windows\system32\utilman.exe.bak
copy d:\windows\system32\cmd.exe d:\windows\system32\utilman.exe

Then reboot your computer and let it start Windows 10.

Change the password

Once at the login screen press CTRL+ALT+DEL and click the icon for the "Utility Manager" in the lower right hand corner. This should launch a command prompt with admin rights. Just type in the following commands:

net user <username> /add
net localgroup administrators <username> /add

This will add a new account to the local admin group. Then close the command prompt and login with the new account, the password will be blank.

Clean up

Delete the C:\Windows\System32\utilman.exe and rename the utilman.exe.bak back to utilman.exe

10Aug/169

Unable to delete file: System cannot find the file specified

Running hybrid systems spanning from windows to different flavors of Linux sometimes present you with interesting behavior. One that I have faced every now and then is files that you can't delete due to special characters in the filename. They do show up in the file explorer but when you try to delete them you get "Item not find" or similar error. Seen a lot of different solutions online with third party software and other complex solutions but there is two simple "built-in" ways to deal with this in windows.

dir /x method

Open up a cmd window and navigate to the folder in question. Run a simple dir /x command and it will list the files with the non-8dot3 short names. Then you can just go del {non-8.3-filename} and you will get rid of the file.

rd /s "\\?\c:\temp" method

Not all files generate the non-8dot3 name for some reason, don't ask me why - didn't dig that deep. For this there is a solution as well. In this scenario make sure that the files you want to get rid of are the only one/ones in the directory and run rd /s "\\?\C:\folder\containing\problem\file". This command will remove all the files and the directory as well.

20May/160

BtSync: Refuses to connect to any peers

Have a few ARM based nodes running BitTorrent Sync (btsync) and needed to re-install one of them. Trying to remove it I ended up with my main node (owner) for all my folders to stop connecting to peers or accepting incoming connections. Took me a while to figure out a solution and I couldn't find much about it on the forums or when I googled so I thought I'll share this quick story.

Background

This applies, in my case at least, to the distribution installed via apt-get from YeaSoft. After reading a forum thread about how to remove old and abandoned peers I decided to set the peer_expiration_days setting to 0 to clean the old peer out. So I used the dpkg-reconfigure btsync command and set it to 0. The old peers where cleaned out so I went back to revert the config back to it's original. In the "wizard" it stated that leaving it blank would render the default value of 7 days. So I removed the 0 and saved the configuration. This might have been a mistake on my part but the configuration tool actually seems broken in this distribution.

Error

After doing that I could not set the value via dpkg-reconfigure btsync to anything else and no peers could connect or where contacted. Right after recycling the daemon they showed up for a few seconds and then disconnected. Since I'm running the free, unlicensed version, I can't switch owner of the folders so I had to get this online again. Changing config files didn't matter since they were, as stated in them, overwritten every time the daemon started again.

Solution

Finally I downloaded the latest version from the getsync.com website and unpacked it in the temp folder. Looking at the command line used in the /etc/init.d/btsync script I could find what config file it used. So I started the latest version, which have support for "power user options" in the UI, with the same config file parameter. Went in to the UI and changed the peer_expiration_days back to it's original value, there even is a reset value link. Then shot down the process and started the original daemon with init.d and order where restored.

Tagged as: No Comments