It is not possible. Due to obvious reasons, VHD is it a dynamic structure like a SQL database, whereas WIM is closer to ZIP file – very static and designed for conserving the storage space by compression and links to duplicated files.
What we can do else? We can capture VHD state to WIM. I'm going to perform this operation on Windows 7 machine, so unfortunately this time no PoSH commandlets like Mount-VHD. We will need imageX command, maybe you will need to download and install Windows AIK
Since we need to execute multiple DiskPart commands, we will have to rely on answer files:
diskpart /s attach.txt
imagex /compress maximum /check /scroll /boot /capture F: C:\TEMP\Win7.wim "Win7syspreped"
diskpart /s detach.txt
select vdisk file="C:\TEMP\Win7.vhd"
select vdisk file="C:\TEMP\Win7.vhd"
Now you can compare file sizes J
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:
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
#where are Azure datacenters
#You will need it
#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).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
- 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 . 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 …
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()
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.
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
To restore server's GUI
Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra
P.S. Of course it not works for 2008
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
Add-PswaAuthorizationRule –UserName * -ComputerName * -ConfigurationName *
Let's test it …
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:
- 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
- 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)
CREATE LOGIN [TESTDOMAIN\SQL-2$] FROM WINDOWS
CREATE LOGIN [TESTDOMAIN\SQL-3$] FROM WINDOWS
GRANT CONNECT ON ENDPOINT::[Hadr_endpoint] TO [TESTDOMAIN\SQL-2$]
GRANT CONNECT ON ENDPOINT::[Hadr_endpoint] TO [TESTDOMAIN\SQL-3$]
- We will need to make full backup of our database for initial replication. Use \\UNC\path\
- Eventually we can enable AlwaysOn on the database
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
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
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
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,
foreach ($server in $servers)
$Instance = Get-SCOMClassInstance -Name $server.ToUpper()
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')