February 16, 2018

PowerShell - Query MS SQL Server

This PowerShell script connects to SQL server, queries needed data, exports the results to the CSV file and then sends it via email.

# SQL Server connection string details, integration authentication is used.
$SQLConnectionString = "Server=SQLSERVER\InstanceName;Database=DatabaseName;Integrated Security=SSPI"
# Path to the file for exported data.
$File = "C:\Script\file.csv"
# SQL Query syntax itself.
$SQLQuery = "
select * from DB_Table_Name
"

January 29, 2018

PowerShell - Generate GUID

This PowerShell script uses NewGuid() method of the .Net Framework guid class to generate a Globally Unique Identifier. You can generate 1 GUID by running the script or specify how many GUID’s you want. See example below.

PS C:\> .\generate-guid.ps1
3e8c98a5-b352-4fe4-bcec-6ffe51ae8f84

PS C:\> .\generate-guid.ps1 3
90d92920-f41a-4c3f-86db-516be56edb72
dc9777b7-c3a2-4078-84bc-7fe270b556d6
940033c3-e487-4fd6-ab33-f97201595130


January 16, 2018

PowerShell - Monitoring Windows Service

This PowerShell script checks specific Windows Service. If service is in a stopped state script starts it and creates a log file.

Script usage example:
.\MonitorWindowsService.ps1 -ServiceName "SNMP Trap" -IntervalSeconds 30

Script above checks SNMP Trap service every 30 seconds. Any changes to the service state will be logged in “SNMP Trap_log.txt” file.

December 19, 2017

Office 2016 ProPlus - First Run ADMX

Some policy settings which are not included in a default Office 2016 ADMX file. The policy allows accepting all first run popups and disables default file type selection (XML/OpenDocument) during first run. Both files can be downloaded in a single archive here.


December 11, 2017

Group Policy - Loopback processing or WMI filters

Continue of previous post Group Policy - Processing Order. This post shows an example of solving Group Policy task, where some group policy needs to be excluded from applying on a specific computer. 

Let’s start what we have. There is a parent Organizational Unit called “TEST_OU”. Inside we have Computers and Users OU’s as on a screenshot below.

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

.SYNOPSIS
Gets detailed mailbox statistic information in Exchange Online

.DESCRIPTION
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 ]