Waclaw Chrabaszcz
... there is no spoon ...

PowerShell – Sexy PoSH console

PowerShell don't has to be boring.

Download this module: http://www.powertheshell.com/download/modules/PTSAeroConsole.zip

Extract it into C:\Windows\System32\WindowsPowerShell\v1.0\Modules
(you may need to enable both module files by right clicking | Prosperities |Unlock)

Now you can start PowerShell window:


Import-Module PTSAeroConsole



AZURE - Stairway To Heaven


Before you’ll start reading please start to play this song.


OK boys and girls, time get familiar with clouds. Time to become a meteorologist. To be honest I don’t know how to start. Is cloud better or worse than on campus resources … hmm … it is just different. I think for successful adoption in cloud world IT Dinosaurs need to forget some “Private Cloud” virtualization bad habits, and learn new way of thinking.

Take a look:

- I don’t need any  tapes or  CDs  (Physical Kingdom of Windows XP and 2000)

- I don’t need any locally stored MP3s (CD virtualization :-)

- I can just stream music to your computer no matter whether my on-site infrastructure is powered on.

Why not to do exactly the same with WebServer, SQL, or just rented for a while Windows server ? Let’s go, to the other side of the mirror. 1st  - register yourself for free one month trial, as happy MSDN subscriber you’ve got monthly budget to spent. In addition in default setting your limit protects you against loosing real money, if your toys will consume too much traffic and space.


Once your account is ready forget WebPortal, we are PowerShell knights.


#Authenticate yourself in Azure

#download once your settings file

#Import it to your PowerShell Module
Import-AzurePublishSettingsFile "C:\Azure\[filename].publishsettings"


#where are Azure datacenters

#You will need it Smile

#storage account is related to physical location, there are two datacenters on each continent, try nearest to you
# all your VMs will store VHD files on your storage account
#your storage account must be unique globally, so I assume that words account or server are already used
New-AzureStorageAccount -StorageAccountName "[YOUR_STORAGE_ACCOUNT]" -Label "AzureTwo" -Location "West Europe"

#it looks like you are ready to deploy first VM, what templates we can use
Get-AzureVMImage | Select ImageName

#what a mess, let’s choose Server 2012
$ImageName = (Get-AzureVMImage)[74].ImageName

$cloudSvcName = '[YOUR_STORAGE_ACCOUNT]'
$AdminUsername = "[YOUR-ADMIN]"
$adminPassword = '[YOUR_PA$$W0RD]'
$MediaLocation = "West Europe"

$vmnameDC = 'DC01'

#burn baby burn !!!
$vmDC01 = New-AzureVMConfig -Name $vmnameDC -InstanceSize "Small" -ImageName $ImageName   `
    | Add-AzureProvisioningConfig -Windows -Password $adminPassword -AdminUsername $AdminUsername   `
    | New-AzureVM -ServiceName $cloudSvcName

#ice, ice baby …
Get-AzureRemoteDesktopFile -ServiceName "[YOUR_STORAGE_ACCOUNT]" -Name "DC01" -LocalPath "c:\AZURE\DC01.rdp"

As you can see it is not just a new-VM, you need to associate your VM with AzureVMConfig (it sets your template), AzureProvisioningConfig (it sets your customizations), and Storage account. In next releases you’ll need to put this machine in specific subnet, attach a HDD and many more. After second reading I found that I am using the same name for STORAGE and SERVICE account, please be aware of it if you need to split these values.

- pipe rules !
- at the beginning it is hard to change your mind and agree with fact that it is easier to remove and recreate a VM than move it to different subnet Smile
- by default everything is firewalled, limited access to DNS, but NATed outside on custom ports. It is good to check these translations sometimes on the webportal.
- if you remove your VMs your harddrives remains on storage and MS will charge you Smile. Remove-AzureVM -DeleteVHD

For me AZURE it is a lot of fun, once again I can be newbie and learn every page. For me Azure offers real freedom in deployment of VMs without arguing with NetAdmins, WinAdmins, DBAs, PMs and other Change Managers. Unfortunately soon or later they will come to my haven and change it into …


PowerShell – duplicated files in Windows Media Player library

Holiday! .. But why it's raining. Let's cleanup some duplicated MP3s. Maybe the rain will stop in the meantime.

For sure this code is not optimized, and I am not recommending anyone to use it. If you uncomment move actions you can reduce number of duplicated media files in your Windows Media Player library.

You can consider it as an example how to access and browse WMP using PowerShell.


$wmp = New-object –COM WMPlayer.OCX
$playlist = $wmp.mediaCollection.getAll()
do {
if ($playlist.item($i).sourceURL -like "*.mp3")
if ($playlist.item($i).name -eq $playlist.item($i-1).name)
write-host "n-1 : " $playlist.item($i-1).sourceURL
write-host $playlist.item($i).name " : " $playlist.item($i).sourceURL
if ($playlist.item($i).sourceURL.tostring().length -gt $playlist.item($i-1).sourceURL.tostring().length )
Write-Host -ForegroundColor yellow "moving " $playlist.item($i).sourceURL
#Move-Item $playlist.item($i).sourceURL "c:\output"
Write-Host -ForegroundColor red "moving " $playlist.item($i-1).sourceURL
#Move-Item $playlist.item($i-1).sourceURL "c:\output"
while ($i -le ($playlist.count -1))

Ahh .. A quick description, you've got media files in many folders. The script checks WMP library and in case of conflict wins the file with shorter URLpath. To move files uncomment #Move-Item. And let WMP rebuild library before next script run. It may take up to 3 days.

Server 2012 GUI – to be or not to be …

That's the question J

This quick post is inspired by one of feedbacks.

To enter into PowerShell just type powershell in CMD

To make Server 2012 core server:

Uninstall-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra
Shutdown –r


To restore server's GUI


Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra
Shutdown –r

Voila !

P.S. Of course it not works for 2008

Server 2012R2 – PowerShell Web Access

Haha … Sometimes I'm joking that there is nothing worse than Linux fanboi imprisoned in Windows engineer's body. Maybe someday I will start blogging about my noob's experiences. However let's stick to the point. Sometimes the easiest solutions are the best. After couple of tries how to reach left pocket using right hand I'm going to follow easy path. Today's plan is very easy, I'm going to take advantage of Server 2012 and install Web gateway to PowerShell console. After that I would be able execute PoSH from any device including Linux.

Install-WindowsFeature –Name WindowsPowerShellWebAccess –IncludeManagementTools
Install-PswaWebApplication –UseTestCertificate
Add-PswaAuthorizationRule –UserName * -ComputerName * -ConfigurationName *


Let's test it …


SQL 2012 – How to setup AlwaysOn cluster

As an application administrator, or transition engineer I need to store my data on some sort of database. Because SQL itself is not my primary focus I rather prefer "I don't care" solutions. It not means I don't care whether database is running or not. It mean I don't have enough time to become an expert in additional area to setup and understanding e.g. Log Shipping. What's more, it's not my problem only. I'll setup some SQL HA solution and walk away, whereas poor WinAdmin will RDP there day by day with heart palpitations.

Since SQL 2005 we've got two user friendly solutions, unfortunately each has a weak point.

  • SQL Cluster –needs a shared storage, in most cases expensive Enterprise class Disk array. And when we talk about DR scenario, we have to switch to remote location, as a result complexity and difficulty are growing very fast.
  • SQL Mirroring – for some reason not liked by many SQL admins (to be honest I would like to know why), and the weak point is limit to two nodes only.

Now with this background we can start to talk about SQL 2012 AlwaysOn. AlwaysOn thanks to mixing SQL and Server technologies removes mentioned limitations.

  • We can build cluster with more than two nodes – I think Windows Cluster (2008/1012) sets limit of nodes. In most of business cases you won't need more than 4-5 nodes. Only two of them works synchronously and can be failover automatically (HA), other are feed with data asynchronously (DR) and should be failed over manually. Good news, to not waist resources (and licenses) async nodes are not passive and you can use them for read only proposes e.g. reporting. Of course it can remove lot of load from primary production database.
  • We don't need any shared storage, what is huge advantage when we talk about Disaster Recovery scenarios.
  • My poor WinAdmin has his lovely right click tool J

In this exercise we will build typical SQL 2012 AlwaysOn Solution:

  • SQL-1 and SQL-2 will be High Availability pair in primary datacenter
  • SQL-2 will Disaster Recover in secondary DC, we will use SQL-3 for reporting proposes

Let's do it!

In first step on each node we will install cluster feature:

  1. In the second we will build Windows Custer using all nodes

    Read it carefully

    in production I would recommend you to use static IP address
  2. Now you can prepare each SQL instance for clustering

Make sure that both Replication Partners are added into each SQL users:

(an example for SQL-1)

use [master]

  1. We will need to make full backup of our database for initial replication. Use \\UNC\path\

  2. Eventually we can enable AlwaysOn on the database




Voila !

Easter egg – OMG^2 the true PowerShell in bash window

Let's continue this crazy experiment. More or less it should works on any distro in my case it is Ubuntu 13.

The idea is to use wine (Wine Is Not an Emulator J) to install Powershell 2.0 for Windows XP. Wine can emulate W7 or W8 however it refuses to install .MSU packages. To reach our goal we will need to use experimental wine 1.7 or above and EXE file so …

For the science!!!

sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.7 winetricks
wget http://kegel.com/wine/winetricks
bash winetricks -q msxml3 dotnet35sp1
bash winetricks lucida
taskset -c 0 bash winetricks windowscodecs
wget -O ~/.cache/winetricks/WindowsXP-KB968930-x86-ENG/WindowsXP-KB968930-x86-ENG.exe http://download.microsoft.com/download/E/C/E/ECE99583-2003-455D-B681-68DB610B44A4/WindowsXP-KB968930-x86-ENG.exe
cd '~/.cache/winetricks/WindowsXP-KB968930-x86-ENG'
wine ./WindowsXP-KB968930-x86-ENG.exe

wine powershell

Happy Easter!

How to install XenApp 7.5

Ha!Ha! XenApp is back! ... Not exactly ... For me XenApp that's IMA architecture, here we have XenDesktop's FMA. Is it better, that's very good question. For me it is just different. Of course I like Broker-Agent concept, but where's my QFARM command? Based of rumors, not confirmed so far by myself, sessions prelaunching, support for retired Citrix streaming and of course Web Interface is back. Let's check it. Hmm .. Looking into official documentation it is not so sweet, sessions prelaunching for sure has been removed.



To install Delivery Controller execute:

ServerManagerCMD -Install NET-Framework-Core
"D:\x64\XenDesktop Setup\XenDesktopServerSetup.exe" /xenapp /noreboot /quiet /configure_firewall /components CONTROLLER,DESKTOPSTUDIO,DESKTOPDIRECTOR,LICENSESERVER


To install a worker:

ServerManagerCMD -Install NET-Framework-Core
"D:\x64\XenDesktop Setup\XenDesktopVDAsetup.exe" /quiet /components VDA,PLUGINS /controllers XenApp75-1.testdomain.net /enable_remote_assistance /ENABLE_REAL_TIME_TRANSPORT /enable_hdx_ports /nodesktopexperience


After XenDesktop's style Site deployment everything is set and ready … but http://www.youtube.com/watch?v=DkDSP7sdLG8

I'll stay with the true name and features of this product, it is called XenDesktop 7.5, and I really like it …. btw if you agree with me just remove /xenapp from the command line J


SCOM 2012 R2 – How to put servers into Maintenece mode using PowerShell

In more or less ITIL's world you have to monitor availability and performance of your servers. However from time to time you need to apply approved changes, what means temporary unavailability or performance degradation. When we talk about Worldwide organizations, in many cases it is really hard to inform everyone about upcoming changes. Sometimes you don't want to inform anyone, you just don't want to wake up your colleagues at 2:00 AM their local time. So to apply the change in elegant way let's put affected boxes into maintenance mode, SCOM won't bother anyone with fake alarms. To not spend all day on SCOM console, let's use PowerShell for this task.

Import-Module -name OperationsManager
$servers = (`

$Time = ((Get-Date).AddMinutes(30))
$comment = "Change-997: Applying MS hotfixes"
$reason = "ApplicationInstallation"
<# -Reason Valid values are: PlannedOther,
UnplannedOther, PlannedHardwareMaintenance, UnplannedHardwareMaintenance, PlannedHardwareInstallation,
UnplannedHardwareInstallation, PlannedOperatingSystemReconfiguration, UnplannedOperatingSystemReconfiguration,
PlannedApplicationMaintenance, ApplicationInstallation, ApplicationUnresponsive, ApplicationUnstable,
SecurityIssue, LossOfNetworkConnectivity.
foreach ($server in $servers)
$Instance = Get-SCOMClassInstance -Name $server.ToUpper()
Write-Host $Instance
Start-SCOMMaintenanceMode -Instance $Instance -EndTime $Time -Reason $reason -Comment $comment

If you'll have problem with comma formatting try this way:

$servers = ('dc.TESTDOMAIN.net','SQL-1.testdomain.NET')

Windows 8.1 – God bless the miracast

As happy owner of the most sexy ultrabook Samsung NX900 i5 - I always wanted to use my TV as secondary wireless monitor. Why? Number one: for watching movies, number two: as additional display when I work from home. Today's post will be much more related to the lifestyle, than IT technology. However this setup gave me much more excitement than deployment of hundreds stateless VDIs.

Many people still asks themselves: "why should I migrate into Windows 8.1". In my case the answer is Hyper-V and Miracast. Hyper-V because it is easy, free, and efficient hypervisor. Of course if someone love VMware Player or VirtualBox he can stay with it. But personally, I shy a bit, that … as declared and certified Microsoft engineer I know WMware PowerCLI better than Hyper-V PowerShell commandlets . So, good bye Hyper-V GUI, since now everything what I do will be implemented via PowerShell.

But … let's stick to the point.

Consider this post as usecase, not the endorsement of anything in particular. So, we've got i5 Samsung NX900 laptop with Intel 3000 GPU, declared by manufacturer WIDI support and brand new Samsung F6640 TV set.

A little background

WIFI direct - it is a very young streaming standard, your TV set have to support it, otherwise you will need to buy any WIDI or Miracast receiver

Miracast – it is a streaming technology originally designed for Android devices, and in my opinion, it is one step from becoming global standard. If I understood correctly what I read, WIFI direct covers/includes Miracast

Intel WIDI - it is an old PC streaming technology, based on Intel GPU, NIC, and Audio components – your laptop must support it. Since version 3.5 Intel WIDI supports/emulates Miracast streaming.

Windows 8.1 brings out of box support for Miracast

After few failed tries on Windows 7 I decided to upgrade my laptop to 8.1, including the installation of all hotfixes and drivers. During long hours of tests I found that for WIDI it is very important to have PROPER graphics driver, WIDI version, (WTF !!!) Network adapter driver and Audio device driver. The easiest way to reach it is to install Intel WIDI update tool: http://supportkb.intel.com/wireless/wireless-display/templates/selfservice/intelwidi/#portal/1026/article/16168 . It will download and install all required components for you. My current configuration:

Get-WmiObject -Class Win32_product|where { $_.Name -like "*Intel*"} | Format-Table Name,Version

Name Version
---- -------
Intel(R) WiDi
System Requirements Lab for Intel
Intel(R) PRO/Wireless Driver 16.07.0000.0730
Intel(R) PROSet/Wireless Software for Bluetooth(R) Technology 2.6.1209.0268
Intel® PROSet/Wireless WiFi Software
Intel(R) Update Manager
Intel® Trusted Connect Service Client 1.24.388.1

My apologies, but I'm not going to break original PowerShell formatting. Once you install all required drivers, reboot your laptop and in the meantime make sure that you have the most recent firmware installed on your TV. Don't forget to connect your TV to your home network. Windows 8.1 should install couple of hotfixes, and after the reboot you'll be able to discover your TV set in WIDI software as well as device in your Settings | Change PC settings.

I noticed about 1 second delay on streamed screen, so for gaming you'll still need to relay on HDMI cable, in any other scenarios it works perfect.

Maybe my method is not efficient but for sure it works …