Friday, 25 October 2013

Customising the Windows 8 Start Screen Layout

I've spent considerable time recently trying to work out how to deploy a custom start screen layout for some Windows 8 tablets we're deploying to a large UK retailer and have finally got it working.

Having investigated several options I kept bouncing between OblyTile and Ben Hunter's Deployment Guys post (http://blogs.technet.com/b/deploymentguys/archive/2012/10/26/start-screen-customization-with-mdt.aspx)

I very much struggle to understand why Microsoft haven't made this an easy to configure option given how much value a properly customised Start screen will add to users. From reading all the information out there it seemed that the device would need to be sysprepped before obtaining the AppsFolderLayout.bin file or an unattend.xml file would work. Either way the start screen wouldn't have the high quality tiles OblyTile is able to help create.

I've since managed to get this working in a much simpler way where the files can be created by one user and then using simple copy commands or a simple batch file used to copy the files to the Default User account.

Note: I'm not sure whether this will work on the newly released Windows 8.1.

Procedure:

Step 1: Log in to a Windows 8 tablet using any domain account.

Step 2: Remove the read only flag on the following file:
C:\Users\{Account Name}\AppData\Local\Microsoft\Windows\appsFolder.itemdata-ms

Step 3: Launch the OblyTile application (version 0.9.1 or later) elevated. Click the Settings icon and ensure the tiles are created for All Users. Select the name, icon image and URL links as appropriate. Create the tiles. In the modern interface start screen rearrange the tiles into the order desired. Zoom out to rename/name groups.

Step 4: Copy the C:\Users\{Account Name}\AppData\Local\Microsoft\Windows\appsFolder.itemdata-ms file to USB:\Tiles\AppsFolder\appsFolder.itemdata-ms

Step 5: Copy the contents of C:\Program Files\OblyTile to USB:\Tiles\OblyTile

Step 6: Copy the contents of C:\ProgramData\Microsoft\Windows\Start Menu to USB:\Tiles\OblyTile

Step 7: Create a batch file called runme.cmd at USB:\Tiles\Runme.cmd with the following contents:

@echo off
xcopy ProgramData\*.* "C:\ProgramData\Microsoft\Windows\Start Menu" /s /y
REM attrib -r "C:\Users\Default\AppData\Local\Microsoft\Windows\appsFolder.itemdata-ms.bak"
attrib -r "C:\Users\Default\AppData\Local\Microsoft\Windows\appsFolder.itemdata-ms"
xcopy AppsFolder\*.* "C:\Users\Default\AppData\Local\Microsoft\Windows" /s /y
if not exist "C:\Program Files\OblyTile" md "C:\Program Files\OblyTile"
xcopy OblyTile\*.* "C:\Program Files\OblyTile" /s /y
attrib +r "C:\Users\Default\AppData\Local\Microsoft\Windows\appsFolder.itemdata-ms"
REM attrib +r "C:\Users\Default\AppData\Local\Microsoft\Windows\appsFolder.itemdata-ms.bak"


Step 8: The USB:\Tiles\Runme.cmd file should be run at an elevated command prompt on any tablet to update the Start Screen layout for all new users logging on to the tablet or add as a deployment task in MDT / SCCM.

Saturday, 25 February 2012

PowerShell script to launch Netflix in UK / US mode

I'm a Netflix subscriber in the UK and it was brought to my attention that Netflix can be launched in US mode by changing which DNS servers you point at. This then allows you to access different content based on the location. As I use my Media Center PC to display content I figured a nice desktop icon would be a good option.

This caused me to write the following PowerShell script to automate the whole process.
The script gets your existing DNS entries (multiple NICs work) and saves them to a file. It then changes the DNS entries of all IP enabled NICs to those specified in the script (I've used Sky DNS servers for the UK ones). It then launches IE and points to www.netflix.com in a Theater style window. At that point the script waits for IE to be closed then it reverts the DNS entries on the NICs back to their original settings.

I've tested this on two machines so far; one with a single external NIC and one with two external NICs. This now works for me.

I created the Netflix US shortcut on the desktop with the following line:

powershell.exe -command "& 'C:\PATH\netflix.ps1' US"

I created the Netflix UK shortcut on the desktop with the following line:

powershell.exe -command "& 'C:\PATH\netflix.ps1' UK"

Give it a try and let me know how you get on...
---------------------------------------------------------------------------------------------------------------------------
Param
([String]$DNS)
$DNSUK = "90.207.238.97","90.207.238.99"
$DNSUS = "208.122.23.22","208.122.23.23"
$Website = "www.netflix.com"
IF
($DNS -eq "UK")
{$SetDNS = $DNSUK}
ELSEIF
($DNS -eq "US")
{$SetDNS = $DNSUS}
ELSE
{"You need to specify UK or US. i.e. Netflix.ps1 UK"
EXIT
}
#Let's obtain your current DNS settings
$NICs = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled=True"
$File = New-Item -type file "NIC Information.txt" -Force
foreach ($NIC in $NICs)
{
$NICName = $NIC.Description

$OriginalDNS = $NIC.DNSServerSearchOrder
$DHCPSetting = $NIC.DHCPEnabled
#Let's determine if you're a DHCP client
#---------------------------------------
if
($DHCPSetting -eq "True")
{"Your DNS servers are automatically assigned"
add-content $file "$NICName,$DHCPSetting,NULL"}
ELSE
{"Your DNS servers are manually set to: $OriginalDNS"
add-content $file "$NICName,$DHCPSetting,$OriginalDNS"}

#Set DNS Setting to location specified
#-------------------------------------
$NIC.SetDNSServerSearchOrder($SetDNS)
"For this session your DNS has been changed to $SetDNS"
#END of foreach
}
#Open Internet Explorer
#----------------------
$IE=New-Object -com internetexplorer.application
$IE.Navigate2($website)
$IE.visible=$true
$IE.TheaterMode=$true

#Monitor Internet Explorer process
#---------------------------------
"Waiting for Internet Explorer window to close"
(Get-Process -Name iexplore)| Where-Object {$_.MainWindowHandle -eq $ie.HWND}| Wait-Process
#Set DNS back to original setting
#--------------------------------
$list=Get-content ".\NIC Information.txt"
Foreach ($line in $list)
{
 $splitLine = $line.split(",")
 $Desc = $splitLine[0]
 $DHCPStatus = $splitLine[1]
 $DNSFromFile = $splitLine[2]

if
($DHCPStatus -eq "True")
{
"DHCP was enabled on adapter $Desc"
$NICs = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled=True" | where{$_.Description -eq "$Desc"}
$NICs.SetDNSServerSearchOrder()
}
ELSE
{
"DHCP was not enabled on adapter $Desc"
$SetDNS=$DNSFromFile
$NICs.SetDNSServerSearchOrder($SetDNS)
}
#End of foreach
}
del ".\NIC Information.txt"

Saturday, 11 February 2012

Create VHD (PowerShell version)

In an attempt to learn PowerShell I've updated the CreateVHD script. It should now be saved as CreateVHD.ps1. The same parameters as before are required:

CreateVHD.ps1 {VHD Name} {Size in GB} {Configure BootFromVHD : YES}

A new feature of this version is that it creates a batch file to remove the GUID entry from the boot process using BCDEDIT. The new file will be named Delete - {VHD Name}.cmd.

See previous post for more information: http://matt-gelder.blogspot.com/2012/02/script-to-create-vhd-populate-it-from.html
_________________________________________________________________________

#Define Parameters Section
#-------------------------
Param
(
[String]$VDisk,
[INT16]$DiskSizeGB,
[String]$BootFromVHD
)
#Variables section
#-----------------
$WimFile = "E:\Sources\install.wim"
$ImageIndex = 1
$TargetDrive = "C:"
$VHDFolder = "\VMs"
#Verify parameters meet conditions
#---------------------------------
if
($VDisk -eq "")
{"You need to specify a name for the Virtual Disk file {Parameter 1}"
EXIT
}
ELSE
{
$VDiskFP = "$TargetDrive$VHDFolder\$VDisk.vhd"
"Virtual Hard Disk Name: $VDiskFP"}
if
($DiskSizeGB -eq "")
{"You need to specify a disk size in GB {Parameter 2}"
EXIT
}
ELSE
{
$DiskSizeMB = $DiskSizeGB * 1024
"Disk size is $($DiskSizeMB)MB"
}
if
($BootFromVHD -eq "")
{"Boot from VHD will not be enabled"}
ELSEIF
($BootFromVHD -eq "YES")
{"Boot from VHD will be enabled"}
ELSE
{"Boot From VHD if specified must be set to Yes {Parameter 3}"
EXIT
}
if
((Test-Path -path $VDiskFP) -eq $True)
{
"Error: $VDiskFP already exists"
EXIT
}
#Create the Diskpart-create.txt file
#-----------------------------------
$File = New-Item -type file "Diskpart-create.txt" -Force
add-content $file "create vdisk file=$VDiskFP maximum=$DiskSizeMB type=expandable"
add-content $file "select vdisk file=$VDiskFP"
add-content $file "attach vdisk"
add-content $file "create partition primary"
add-content $file "format quick FS=NTFS label=$VDiskFP"
add-content $file "assign letter=v"
add-content $file "active"
diskpart /s Diskpart-create.txt
del diskpart-create.txt
#ImageX
#------
"Applying Windows image No. $ImageIndex from $WimFile to $VDiskFP"
.\imagex /apply $WimFile $ImageIndex V:
bcdboot V:\Windows /s V:

#Create the Diskpart-detach.txt file
#-----------------------------------
$File = New-Item -type file "Diskpart-detach.txt" -Force
add-content $file "select vdisk file=$VDiskFP"
add-content $file "detach vdisk"
diskpart /s Diskpart-detach.txt
del diskpart-detach.txt
#Create the Boot From VHD Menu Option
#------------------------------------
IF
($BootFromVHD -eq "YES")
{
$VdiskBCD = ('"{0}"' -f $VDisk)
$VdiskBCD = " bcdedit /copy {current} /d $VdiskBCD "
$VdiskBCD = ('"{0}"' -f $VDiskBCD)
$VdiskBCD = "cmd /c $VdiskBCD > GUID.txt"
$File = New-Item -type file "RunBCD.cmd" -Force
add-content $file "@echo off"
add-content $file "$VdiskBCD"
.\RunBCD.cmd
del .\RunBCD.cmd
$GUID = get-content .\GUID.txt
$GUID = $GUID -split "to ", 2
$GUID = $GUID -split ".", 0, "simplematch"
$GUID = $GUID[1]
del .\GUID.txt
cmd /c "bcdedit /set $GUID device vhd=[locate]$VHDFolder\$Vdisk.vhd"
cmd /c "bcdedit /set $GUID osdevice vhd=[locate]$VHDFolder\$Vdisk.vhd"
cmd /c "bcdedit /set $GUID detecthal on"
cmd /c "bcdedit /default $GUID"

#Create a batch file to remove the GUID from the boot config
$File = New-Item -type file "Delete - $Vdisk.cmd" -Force
$DeleteGUID = "bcdedit /delete $GUID"
$DeleteGUID = ('"{0}"' -f $DeleteGUID)
$DeleteGUID = "cmd /c $DeleteGUID"
add-content $file "$DeleteGUID"
}

Monday, 6 February 2012

Script to create VHD, populate it from WIM file and then set the boot from VHD option

I've been working in my lab environment at home on the Private Cloud stuff and I tend to use Oracle's VirtualBox product. I decided that I wanted to change one of my machines to be a physical box though as I'm somewhat resource constrained. Normally I use the VBoxmanage clonehd to clone my Sysprepped base machine; however that's not going to work in the physical world. So I fired up my BaseVM using a Win 2008 R2 setup DVD, imagex'd the drive and transferred my new WIM file out to my host machine.

I then wrote the following script which creates the VHD file using diskpart, populates it using imagex, detaches the disk and then optionally adds the VHD file to the boot from VHD option on Win7 / 2008 R2. This allows me to fire up a new machine fairly quickly on either physical or virtual hardware. Given the VHD nature of the file it's also even easier to switch to different hypervisors such as Hyper-V.

Note1: The credit for some of the script belongs to Dan Stolts from the following article: http://blogs.technet.com/b/danstolts/archive/2011/03/29/how-to-automatically-create-bcdedit-data-for-a-boot2vhd-file-on-your-windows-7-or-windows-server-2008-r2-machine.aspx
Note2: You will also need imagex.exe either in the same location as the script or in a pathed location.
Note3: Remember to specify your variables in the variables section.

------SAVE BELOW AS A .CMD/.BAT FILE-------------

@ECHO OFF
REM This batch file will perform the following actions
REM
REM Create a virtual disk (VHD format)with the name of the first parameter
REM with a size in GB of the second parameter
REM
REM It will then attach the disk to the local machine and apply the image from the WIM file specified
REM It will then detach the disk
REM
REM If the optional YES 3rd parameter is set it will then add the VHD as a boot option to the local machine
cls
REM Verify Parameters are set correctly
REM ===================================
if "%1" == "" (
    goto :Usage
)
if "%2" == "" (
    goto :Usage
)
if "%3" == "YES" (
    goto :Continue
)
if "%3" == "yes" (
    goto :Continue
)
if "%3" == "Yes" (
    goto :Continue
)
if "%3" == "" (
    goto :Continue
)
goto Usage
:Continue
REM Variables Section
REM =================
set VHD=%1
set Size=%2
set WimFile=C:\VMs\BaseVM.wim
set ImageIndex=1
set TargetDrive=C:
set VHDFolder=\VMs
if exist %TargetDrive%%VHDFolder%\%1.vhd goto ErrorExist
REM Diskpart Section
REM ================
ECHO Creating VHD file %TargetDrive%%VHDFolder%\%1.vhd with a maximum size of %Size%GB
IF EXIST Diskpart-Create.txt DEL Diskpart-Create.txt
ECHO create vdisk file=%TargetDrive%%VHDFolder%\%1.vhd maximum=%size0 type=expandable > Diskpart-create.txt
ECHO select vdisk file=%TargetDrive%%VHDFolder%\%1.vhd>> Diskpart-create.txt
ECHO attach vdisk >> Diskpart-create.txt
ECHO create partition primary >> Diskpart-create.txt
ECHO format quick FS=NTFS label=OS >> Diskpart-create.txt
ECHO assign letter=v >> Diskpart-create.txt
ECHO active >> Diskpart-create.txt
ECHO exit >> Diskpart-create.txt
diskpart /s Diskpart-create.txt
REM Imagex Section
REM ==============
ECHO Applying image
imagex /apply %WimFile% %ImageIndex% V:
bcdboot V:\Windows /s V:

REM Detach VHD
REM ==========
ECHO Detaching Image
IF EXIST Diskpart-Detach.txt DEL Diskpart-Detach.txt
ECHO select vdisk file=%TargetDrive%%VHDFolder%\%1.vhd > Diskpart-Detach.txt
ECHO detach vdisk >> Diskpart-Detach.txt
diskpart /s Diskpart-Detach.txt

REM Add VHD to Boot Menu
REM ====================

if "%3" == "YES" (
    goto :Boot2VHD
)
if "%3" == "yes" (
    goto :Boot2VHD
)
if "%3" == "Yes" (
    goto :Boot2VHD
)
if "%3" == "" (
    goto :End
)
goto Usage

:Boot2VHD
set VHDFILENAME=%1
set VHDDESC="Boot from VHD"
@echo VHDFileName=%1
@echo Creating VHD boot entry for %VHDDESC%....
cmd /c " bcdedit /copy {current} /d %VHDDESC% " > VHDGUID.txt
FOR /F "tokens=7 delims=. " %%A in (VHDGUID.txt) DO set GUID=%%A
@echo VHD boot entry GUID = %GUID%
set BCDFName=%VHDFolder%\%1.vhd
@echo Configuring VHD boot entry....
@echo setting Device... vhd=[locate]%BCDFName%
bcdedit /set %GUID% device vhd=[locate]%BCDFName%
@echo setting OSDevice... vhd=[locate]%BCDFName%
bcdedit /set %GUID% osdevice vhd=[locate]%BCDFName%
bcdedit /set %GUID% detecthal on
bcdedit /default %GUID%
Goto End
:ErrorExist
ECHO The file %TargetDrive%%VHDFolder%\%1.vhd already exists. Please delete before recreating
goto End
:Usage
ECHO Please specify both {Name} and {Size in GB} parameters
ECHO.
ECHO Optional 3rd parameter: Specify YES to add Boot2VHD feature on local machine
ECHO.
ECHO E.G. CreateVHD.cmd Win2008R2 100 YES
:End
if exist Diskpart-create.txt del Diskpart-create.txt
if exist Diskpart-detach.txt del Diskpart-detach.txt
if exist VHDGUID.txt del VHDGUID.txt

Wednesday, 4 January 2012

DFS Share Command Line

On my home server I've configured a DFS share to present one shared folder to include files from 2 shared folders on separate hard disks. The script needs to be run every time a new folder is added to either of the shared folders.

This script is below:

-------------------------------------------------------------------------
@echo off
REM Clean up section
dfsutil root remove "\\MEDIA\TV Shows"
net share "TV Shows" /DELETE
rd "E:\ServerFolders\TV Shows"
REM Query the folders and output to two temp text files
dir \\MEDIA\TV1 /ad /b> TempTV1.txt
dir \\MEDIA\TV2 /ad /b> TempTV2.txt

md "E:\ServerFolders\TV Shows"
net share "TV Shows"="E:\ServerFolders\TV Shows"
dfsutil root addstd "\\MEDIA\TV Shows"
for /F "delims=*(()(" %%1 IN (TempTV1.txt) DO dfsutil link add "\\MEDIA\TV Shows\%%1" "\\MEDIA\TV1\%%1" "%%1"
for /F "delims=*(()(" %%1 IN (TempTV2.txt) DO dfsutil link add "\\MEDIA\TV Shows\%%1" "\\MEDIA\TV2\%%1" "%%1"
del TempTV1.txt
del TempTV2.txt

Tuesday, 3 January 2012

What the hell is a private cloud?

This can be seen as a cynics journey into the cloud. Over the last 5 or so years everyone's talked about cloud computing with no one really having a clue. Now it seems that the cloud is starting to arrive and I figure it's time to find out what it is.
Step 1 : Learn what the hell is a cloud...

My first port of call is the Microsoft Virtual Academy. A free Microsoft resource set up as if it's an online college. Clearly very Microsoft focussed but that's good when you want to learn Microsoft products.

Track: Microsoft Private Cloud Infrastructure

https://www.microsoftvirtualacademy.com/tracks/microsoft-private-cloud-infrastructure-

Module 1: Microsoft Private Cloud Infrastructure - Overview
Link to video: http://technet.microsoft.com/en-us/edge/microsoft-virtual-academy-microsoft-private-cloud-infrastructure-module-1-microsoft-private-cloud-infrastructure-overview

My review of the first one: Very informative video - had to download it via WMV file though as streaming it stopped in a couple of places and it refused to rebuffer. The accompanying PDF file supplied all the supporting text that the presenter read which is useful. The exam however failed miserably as question #5 did not have any answers listed which made it tricky to answer - I have had to wait for it to time out twice now to let me try and pass the module.

Still - despite this issue a very good start.

Module 2: Microsoft Private Cloud Infrastructure - Configuration
Link to video: http://technet.microsoft.com/en-us/edge/microsoft-private-cloud-infrastructure-configuration

The second one continued in the same format with a very good level of information, I already know a fair bit about Windows clustering and Hyper-V so not too much in depth learning required. It's a good source to define what a private cloud is and how the components fit together.

Module 3: Microsoft Private Cloud Infrastructure - Management
Link to video: http://technet.microsoft.com/en-us/edge/microsoft-private-cloud-infrastructure-management

The third one continued in the same style but focussed around management. Lots more information about best practices.

Overall this course was very useful in giving an overview of the Private Cloud. I'm itching now though to start to get to the nitty gritty details. High level information is useful to understand everything but I'm one of those people who needs to see it working.

So I now know what a Microsoft Private Cloud is and what components comprise it. At the minute it seems to be in a state of transition with the new 2012 generation of System Center products coming out.


Having done the first track I moved onto the second applicable one on the MVA website.

Track 2 : Planning, Building and Managing a Private Cloud

https://www.microsoftvirtualacademy.com/tracks/planning-building-and-managing-a-private-cloud

I think this was a useful track to do as well. The first module was very much aimed at promoting the cloud experience (which wasn't really what I was looking for). I accidentally switched my brain off a couple of time during this one. The presenter didn't really inspire me that much. The second module had Symon Perriman from the first track who I thought did a great job so that was ok. The second and third modules had a lot more screencasts which I find useful. Overall though most of the information was already provided in the first track but it certainly didn't hurt to get it again.

A quick summary

But basically a private cloud comprises a companies locally hosted hyper-v servers running guest machines. It is like a traditional virtualised environment with a suite of management tools wrapped around it. The core features are:

Windows Server 2008 R2 running Hyper-V
Active Directory, DNS, DHCP
System Center Virtual Machine Manager 2008 / 2012
System Center Operations Manager 2007 R2 / 2012
System Center Configuration Manager 2007 R3 / 2012
System Center Opalis / Orchestrator
System Center Service Manager 2010 / 2012
System Center DPM 2010 / 2012

You certainly get the impression from the videos that the 2012 products have been designed with Private Clouds in mind specifically the VMM 2012.

As a quick overview:

System Center Virtual Machine Manager (SCVMM) is used to control/manage/configure the virtual machines running on the Hyper-V hosts

System Center Operations Manager (SCOM) is used to provide software and hardware monitoring of the hosts and guests as well as providing troubleshooting information and PRO tips to SCVMM to control VM placement.

System Center Configuration Manager (SCCM) is used to provide software updates, software installation, license management, OS deployment, software/hardware inventory, reporting and script deployment.

System Center Opalis / Orchestrator is used as a work flow tool to create custom actions using a graphical user interface; this integrates well into the System Center Service Manager.

System Center Service Manager (SCSM) is used to provide helpdesk services as well as being able to respond to certain conditions. For instance if SCOM raises an alert into SCSM a rule can be configured to run an Opalis/Orchestrator work flow to go and resolve that issue.

System Center Data Protection Manager (SCDPM) is used to provide backup / restore services.

My next steps...

Well having gained an understanding of what a Private Cloud is I figure I now need to go and learn the additional components I don't know. Given I already know SCCM, SCVMM, Hyper-V and failover clustering I am planning on tackling SCOM next. I think I'm going to do SCOM 2007 R2 first and then 2012. I don't expect to get a thorough in depth knowledge but hopefully enough to be able to implement it in a private cloud, deploy agents, deploy management packs and install the PRO tips for SCVMM.

Wednesday, 3 August 2011

Search Providers using Internet Explorer Administration Kit 9

How to enable Google UK as a search provider in IE9

I got a new Windows 7 laptop a couple of months ago and as is my way I decided to install IE9 on it. My only problem was that Bing was set as the default search provider. While there's nothing wrong with Bing for searching I do generally use Google and wanted to make the change. So in the combined search/URL box I click the drop down arrow and selected Add taking me to the Internet Explorer Gallery where I was completely unable to select Google. I set the focus on Search and on Search Providers but still couldn't find Google. I figured something odd was happening with my machine until a couple of weeks later my brother said he was having the same thing when installing Win7 on his Mac.

The solution I discovered was to google "Search Providers" and use the Microsoft link http://www.microsoft.com/windows/ie/searchguide/en-en/default.mspx to use the traditional method for selecting Google UK.

How to enable Google UK as a search provider through IEAK 9

This useful knowledge came in handy yesterday. I'm currently playing about with ConfigMgr 2012 Beta 2 and MDT 2012 to create a Windows 7 image. As part of this I want to include IE9 as part of the reference image.

So I fired up IEAK 9 and went through the steps to create the image. After a fair bit of googling/binging about I struggled to find the URL string required to set the default search provider in IE9 to Google UK. So using the Microsoft link above I followed the "Create Your Own" section.

  • Go to www.google.co.uk (or whichever search engine you want)
  • Search for TEST
  • Paste the URL back into the box under Create Your Own
  • Enter the name as Google UK
  • Then click View XML
  • Now you can copy everything between the quotes under the template section and use that in IEAK9