Sunday, 3 August 2014

Adelaide Windows User Group - PowerShell 301

Some more PowerShell from me, this time at this week's meeting of the Adelaide Windows User Group:

If you're not automating repetitive tasks with PowerShell, you're probably doing it wrong! In this presentation, after a quick language recap, we'll look at a number of best practices that will make your scripts even better. We'll look at tips for reliability, ease of use and making your scripts work just like the built-in cmdlets.
To top things off, we'll also give a brief overview of PowerShell 4.0's new Desired State Configuration feature.

Yes, it's similar to the talk I did at the .NET Group last month, but instead of covering hosting PowerShell in your own app, we'll spend a bit more time looking at DSC.

The group meets this Tuesday August 5th 2014 12-1pm at Microsoft Adelaide, Level 12, Aurora Building, 147 Pirie Street, Adelaide.

RSVP to Pete at adlwug@live.com.au if you plan on coming. It would be great to see you there!

Monday, 14 July 2014

Disabling NO_CI using 2013 build process templates

Like Philipp, I just noticed that the new simplified 2013 build templates still don't provide an obvious way to prevent a gated checkin build from appending "**NO_CI**" to the checkin comment, preventing subsequent continuous integration or rolling builds from running.

I had a look around and discovered that rather than the old SyncWorkspace activity, the new TfGetSources activity looks like the right place to go to:

image

I was slightly confused, as reviewing the current class documentation doesn't list the property. And it turns out that indeed for TFS 2013 RTM, this property didn't exist (I found this out the hard way – a workflow that references that property will fail when run on such an environment).

Comparing the two C:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Activities.dll files (from two different machines) in Reflector reveals the following:

2013 RTM (File version 12.0.21005.1)
image

2013 Update 2 (File version 12.0.30324.0)
image

A useful change introduced in Update 2.

Saturday, 12 July 2014

Dell XPS 1645, Windows 8.1 and Bluetooth

My trusty Dell laptop is still going strong 4 years on. It's showing signs of being well used - the screen is a bit scratched in places, most of the rubber feet have fallen off and the battery doesn't last as long as it used to, but it does the job.

Until recently I hadn't really needed to use any Bluetooth devices, and it was then that I realised that Bluetooth had somehow disappeared. The Bluetooth status light on the front of the case would blink briefly when booting up but then stay off, and there was no Bluetooth icon in the Windows system tray. I'm sure these used to be there originally! A bit of Googling revealed that it was probably upgrading to Windows 8/8.1 that would have disabled it, due to out-dated/incompatible drivers.

I downloaded the latest Dell Wireless 370 Bluetooth Minicard Application, but after it self-extracted, the installer was prevented from running by the Windows Program Compatibility Assistant. Sometimes you get the option to proceed with caution, but in this case not.. Or so it seemed.

Window Program Compatibility Assistant warning dialog

Next, I wondered if I could get newer drivers directly from Broadcom? Well yes you can – from http://www.broadcom.com/support/bluetooth/update.php, but after downloading and running the app it wanted to see the existing Bluetooth device (as it presumably then goes and downloads specific drivers for your devices). But that's the problem, I can't get the device working in the first place!

I came across this post - http://www.wiknix.com/solved-bluetooth-device-not-working-in-windows-8/ which at first glance looked like one of those annoying content aggregation sites, but in this case either the site is legitimate, or at least the instructions were valid. To repeat the relevant steps here:

  1. Go to C:\dell\drivers\R226750\R226750\Win64
  2. Run BtwMM.exe
  3. Run Inst.exe

This time, the drivers installed and bingo, I had Bluetooth devices appearing!

Figuring there's probably a good reason that Windows wasn't keen on these older drivers, I then re-tried the Broadcom Software Update application.

Broadcom Bluetooth Software Download application screenshot

This time, it detected the existing Bluetooth devices and so could proceed to download and update the drivers to newer versions (that apparently do properly support Windows 8/8.1).

Rebooting, I noticed that now just a 'generic' Bluetooth device was listed in Device Manager. Right-clicking on this and choosing Update Driver Software, it then updated the driver back to the Dell Wireless 370 Bluetooth Mini-card (version 12.0.0.8047)

Device Manager now looks like this (yes, my laptop is named 'Clarabel' Smile)

Windows Device Manager, showing Bluetooth devices

And there's the Bluetooth icon in the system tray again:

Windows System Tray showing Bluetooth icon

We're good to go!

Monday, 7 July 2014

SSDT BI Install Logs

A short note for my reference. When you install SQL Server Data Tools – Business Intelligence for Visual Studio 2013, the installer writes a log file to a folder under C:\Program Files (x86)\Microsoft SQL Server\120\Setup Bootstrap\Log\

Handy if you’re trying to install it remotely or via an unattended install file and need to diagnose any errors.

Monday, 30 June 2014

ADNUG–PowerShell for Developers

I'm presenting at the July meeting of the Adelaide .NET User Group.

If you're not automating repetitive tasks with PowerShell, you're probably doing it wrong! In this presentation I will give a quick introduction to PowerShell (including some recommended practices) and then dive deeper into how you can use PowerShell as part of your TFS build process and how you can even host PowerShell in your own .NET applications.

6pm, Wednesday 9th July 2014

Marcellina Adelaide
273 Hindley Street, (Cnr Gray St) Adelaide

($5 for pizza, free if you're an ADNUG member)

Register via the ACS Events site

Hope to see you there!

Tuesday, 10 June 2014

Lumia 920–Stuck in ‘headphones’ mode

Last month after watching the demos from the Microsoft Build conference on the updates to Windows Phone, I decided to take the plunge and update my phone to Windows Phone 8.1. All was going well and some of the new features were really nice – improved keyboard, the notification centre, and VPN support to name a few.

Then all of a sudden a few weeks later my handset wouldn't acknowledge that my headphones were no longer plugged in. It thought they were always plugged in, so didn't play audio through the speaker – making receiving phone calls tricky as you either had to switch the call to 'hands free', or to quickly plug the headphones back in.

A few others seemed to be in the same boat, but subsequent updates for 8.1 didn't resolve the issue. The original reporter then sent his phone off to be checked under warranty. I decided to do the same – for while the problem happened after I'd upgraded to 8.1, there don't seem to be heaps of people with the same problem, so maybe it was more a coincidence and just a regular mechanical fault with the headphone jack.

The only tricky bit was proving to Nokia that it was my phone (I'd won it from Microsoft so I didn't have a receipt). After a bit of email tag and a few phone calls they were finally convinced and I posted my handset off to Sydney.

Before being sent off to Nokia Care, I was asked to use the Nokia Software Recovery Tool. This had the interesting effect of downgrading the firmware and OS back to 8.0 (and didn't fix the audio problem, which increased my suspicions that the problem was not software-based)

Here's the details before it was posted off:

imagewp_ss_20140530_0002

Today I finally got it back. They'd replaced the audio jack and the USB jack. Looks like they re-flashed the firmware with the Australian ‘country’ variant of the Lumia Black Update (3051.40000.1349.0007) – Probably better to have ‘RM-821_apac_australia_new_zealand_304’ instead of ‘RM-821_eu_euro1_425’ I suppose.

imagewp_ss_20140610_0002

And yes, the audio is now working!

While my phone was being serviced, I dug up my trusty old Samsung 'dumb' handset and after visiting Vodafone to get a normal-sized SIM I at least was contactable on my mobile (if not online). Conveniently, Vodafone now give out SIMs that you can pop-out the middle to get a micro-SIM, so I didn't need to go back to the Vodafone shop a second time.

WP_20140610_001

Also, thanks to the Windows Phone Backup feature, I am restoring all my apps and settings so my phone is basically back to how it was before all the dramas started! Very convenient.

Next step, to the latest Windows Phone 8.1 release. With a new audio jack fitted, I'm hoping there will be no more issues.

imagewp_ss_20140610_0002 1

Sunday, 25 May 2014

PowerShell Wix Extension

I've looked, but I couldn't find anyone who'd implemented a Wix Extension that would allow running PowerShell scripts. So I've spent a few hours this weekend writing one (and learned a bit more about Wix and MSIs along the way).

This extension allows you to run script from a file that is included in the MSI, or inline script (inside a CDATA section).

By hosting PowerShell in the custom actions, scripts also get access to the $session variable (which is of type Microsoft.Deployment.WindowsInstaller.Session), so you can call $session.Log("Running this") and it will add "Running This" to the MSI log!

Here's an example of what you can do:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:powershell="http://schemas.gardiner.net.au/PowerShellWixExtensionSchema">
  <Product Id="*" Name="PowerShellWixTest" Language="1033" Version="1.0.0.0" Manufacturer="David Gardiner" UpgradeCode="c61298af-d8c9-4179-903f-f42fa69b59ad">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate />

    <Feature Id="ProductFeature" Title="PowerShellWixTest" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
    </Feature>

    <powershell:File Id="PSFile1" File="[#TestPs1]" Arguments="&quot;First Argument&quot; 2"/>

    <powershell:Script Id="Script2">
      <![CDATA[
        
        # Write-Host "Number 2";
        
        for ($i = 1; $i -le 100; $i++) 
        { 
          Write-Progress -Activity "Activity" -Status "Status $i% complete" -CurrentOperation "Operation $i" -PercentComplete $i
          Start-Sleep -Milliseconds 5 
        }
        
        ]]>
    </powershell:Script>
    
    <UI>
      <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
      <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
      <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />

      <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
      <Property Id="WixUI_Mode" Value="Minimal" />

      <DialogRef Id="ErrorDlg" />
      <DialogRef Id="FatalError" />
      <DialogRef Id="FilesInUse" />
      <DialogRef Id="ProgressDlg2" />
      <DialogRef Id="UserExit" />

      <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>

      <Property Id="ARPNOMODIFY" Value="1" />
    </UI>

    <UIRef Id="WixUI_Common" />
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="PowerShellWixTest" />
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <Component Id="ProductComponent">
        <File Id="TestPs1" Source="Test.ps1" KeyPath="yes" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

The code and releases are hosted on GitHub - https://github.com/flcdrg/PowerShellWixExtension

Development resources