November 24, 2017

SSH tunneling example

Example of using SSH tunneling in restricted environment. In this case Server1 is a Linux box (Ubuntu 16.04) located in DMZ and it has only SSH (default tcp 22) in allowed. Using SSH tunnels this Linux box is going to be updated using apt tool.

November 12, 2017

ZFS - Export snapshot to encrypted file

This post shows some basic steps how to install ZFS on Ubuntu 16.04, create ZFS pool and file system. It also will cover snapshot creation and export it to encrypted file.

# Install ZFS tools.
apt install zfsutils-linux

# Create ZFS pool called Pool1 from single disk (/dev/xvdb)
zpool create Pool1 /dev/xvdb -f

October 16, 2017

Exchange Server - Move Archive between mailboxes

Get-Mailbox User1 | ft Name,ArchiveName
Name              ArchiveName
----              -----------
User1             {In-Place Archive - User1}

Get-Mailbox User2 | ft Name,ArchiveName
Name              ArchiveName
----              -----------
User2             {}

Disable-Mailbox User1 -Archive
Disabling the archive for "User1" will remove the archive for this user and mark it in the database for removal.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): Y

October 12, 2017

Exchange Online - Get-MailboxStatisticsDetails

Gets detailed mailbox statistic information in Exchange Online

When you configure cache settings in outlook you need to choose how much data you want to store locally.
This script helps to identify the size of mailbox for specific time range: 3 days, 1 week, 2 weeks 1 month etc. up to 2 years.
It includes information about archive size and items count. The script accepts pipeline and the result can be exported to csv file.

October 5, 2017

XEN - IPFire - Interface doesn't exist

Networking issues with IPFire 2.19 installed as HVM on XEN 4.8 (Ubuntu 17.04).
Network configuration GREEN + RED.
Domain VIF config: vif = ['bridge=xenbr0','bridge=xenbr1']

When you destroy and create IPFire domain you get the warnings below:
Interface green0 doesn't exist.        [ FAIL ]
Interface red0 doesn't exist.          [ FAIL ]

October 3, 2017

Microsoft Azure - Add existing VM to Availability Set

Currently it is not possible to add an existing Azure Virtual Machine to Availability Set. VM needs to be re-created because Availability Set setting can be specified only during deployment stage. Below is a script which automates this process. It is assumed that VM is managed by Resource Manager, OS disk is managed, no data disks are attached and VM has only one nic. The script gathers current information about Virtual Machine and saves it to txt file (Set-AzureVMAS.txt). It includes such fields as VM Name, Extensions, VM Size and NIC, Operating System and Disk information. Then script re-creates Virtual Machine and sets needed Availability Set. $VMName, $ResourceGroup and $AvailabilitySet variables in a header of the script need to be specified. Script also works with VM’s which are already in another AS so can be used to move VM's between Availability Sets.

September 24, 2017

Ubuntu 17.04 with XEN 4.8 and ZFS

# Update packages
apt update && apt upgrade

# Install XEN hypervisor.
apt-get install xen-hypervisor-amd64

# Modify GRUB and reboot.
dpkg-divert --divert /etc/grub.d/08_linux_xen --rename /etc/grub.d/20_linux_xen

# Check that Domain-0 is up and running.
xl list

September 13, 2017

PowerShell - get Process ID of running service

How to get a Process ID of running service using PowerShell?

Get-WmiObject -Class win32_service | where {$_.Name -eq "Service Name"}

Example below will show a Process ID of “Task Scheduler” service:
Get-WmiObject -Class win32_service | where {$_.Name -eq "Schedule"}
ExitCode  : 0
Name      : Schedule
ProcessId : 11900
StartMode : Auto
State     : Running
Status    : OK

Or use more convenient way through Caption property:
Get-WmiObject -Class win32_service | where {$_.Caption -eq "Task Scheduler"}

Want to kill Task Scheduler process?

September 4, 2017

PowerShell - Sea Battle Game

Create 5 submarines and play against computer. Computer generates unique moves and ship placement every new game. Also there is a cheat mode available via (-EnableCheats) parameter to see computer's table.

September 1, 2017

Exchange 2013 - MaxHitsForFullTextIndexSearches

There is Microsoft Exchange 2013 bug, which limits search results by 250 items in Outlook.  

Possible fix can be achieved by amending Microsoft.Exchange.Store.Worker.exe.CONFIG file in BIN folder of your Exchange installation directory. Put the code below after </runtime>: