Sunday 13 August 2017

Windows 2012 Remote Desktop or RemoteApp session log off

To automatically clear disconnected sessions off of your RDS host, open up 'Edit Group Policy' and browse to Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Session Time Limits. Enable the policies 'Set time limit for disconnected sessions' and 'Set time limit for logoff of RemoteApp sessions'. Set both time limits to 5 minutes.

Remotely sending and executing files to Linux servers

1 - Create a file with a list of server names. For this example I will use /home/scott/servers.txt as my list. Each server name should be on a separate line

2 - Setup passwordless login to remote servers using SSH keys unless you want to keep typing in passwords

3 - Create this script for sending the file out to servers. I call this script SEND:

[ $# -lt 2 ] && { echo 'usage: SEND <file to send> <path at remote server>'
echo '  e.g. SEND file1 /home/test '
exit 0
}
echo "Send ${1} to ${2} all servers listed in /home/scott/servers.txt?    y/n "
read i
if test "$i" = y
        then
        for SERVER in `cat /home/scott/servers.txt`
        do
        echo "Sending to ${SERVER}"
        scp -p $1 $SERVER:$2
        done
exit 0
fi
echo 'Not sent!'



4 - Create this script for executing the file you have just sent. I call this script RCMD

[ $# -lt 1 ] && { echo 'usage: RCMD <command-to-run>'
echo ' e.g. RCMD l /home/test '
exit 0
}
echo "Run  ${1} ${2} ${3} ${4} on all servers listed in /home/scott/servers.txt?    y/n "
read i
if test "$i" = y
        then
        for SERVER in `cat /home/scott/servers.txt`
        do
        echo "Running at ${SERVER}"
        ssh $SERVER ${1} ${2} ${3} ${4}
        done
exit 0
fi
echo 'Not run!'




5 - For the file you want to send, run /Path/To/SEND/Script '/Path/To/File/You/Are/Sending' /Where/You/Want/To/Put/It/On/Remote/Server

6 - To execute the file you have just sent, run /Path/To/RCMD/Script '/Path/To/File/On/Remote/Server'

Changing Linux Network Configuration



To make changes to a Linux servers IP configuration, follow the steps below. Use :x to exit the files you are changing to save them: 

Step 1 - Run ifconfig and note the name of the active network interface on the left. As standard this should always be eth0 but for some configurations it may be different

Step 2 - Run vim /etc/sysconfig/network-scripts/ifcfg-InterfaceName


Step 3 - In this file, make your changes to the IPADDR, NETMASK and GATEWAY fields. If there is no gateway field move onto the next step otherwise skip to step 5


Step 4 - Run vim /etc/sysconfig/network and change the gateway


Step 5 - Run service network restart to restart the network interface and pick up the changes. Any connections to the server will be lost when you do this.

Empty log file in Linux

If a log file has grown out of control and you want to empty it out, run the following:


cat /dev/null > /Path/To/Log

This overwrites the file with the contents of /dev/null which is nothing

Exchange 2010 switch all mailboxes over to other server



This applies to DAG's where you have 2 mailbox servers

Open Exchange Management Console 

Under Server Configuration > Mailbox right click the server you want to switch the mailboxes from and click switchover server 

In the pop up that appears tick use the specified server and click browse. Double click the server you want to move the databases to. Click Ok. 

Give it a few minutes then close and reopen the EMC to check all mailboxes show mounted on the server you want them on. It should show healthy for the other server unless there are problems.