Monthly Archive

Categories

Monthly Archives: September 2012

Finding the drive letter of a mounted VHD

In Windows 8/2012 you can mount a VHD into the file system. Is there a way to discover the drive letter of the mounted VHD

function get-mountedvhdDrive {            
$disks = Get-CimInstance -ClassName Win32_DiskDrive | where Caption -eq "Microsoft Virtual Disk"            
foreach ($disk in $disks){            
 $vols = Get-CimAssociatedInstance -CimInstance $disk -ResultClassName Win32_DiskPartition             
 foreach ($vol in $vols){            
   Get-CimAssociatedInstance -CimInstance $vol -ResultClassName Win32_LogicalDisk |            
   where VolumeName -ne 'System Reserved'            
 }            
}            
}

Use Get-CimInstance to get the Win32_DiskDrive class. Filter on caption equalling "Microsoft Virtual Disk"

for each “physical” disk returned get the associated Win32_Volume and use that to get the associated Win32_Logical disk where you will find the drive letter.

Nice example of using associations in the CIM cmdlets

PowerShell Summit Open for registration

The PowerShell summit to be held April 2013 at Microsoft’s Redmond campus is now open for early registration.  There are very good deals available for early registration.

Details and registration link here - http://powershell.org/summit/registration.php

Office 2013, Windows and SkyDrive app revisited

This is not a combination I would recommend based on the current preview.  If the experience doesn’t get better before Office 2013 RTMs I won’t be upgrading.  Every time I open a document I get a message that there is a problem with the document. Is there a problem? In reality no.

Trying to open a second Word document and your machine freezes for a while.

I have lost work because of the interaction between Word’s attempts to communicate with SkyDrive and the Skydrive app.

I’ll persevere a bit more but as I don’t have anything like the problems with Office 2010 I may just revert

PowerShell Summit April 2013

A PowerShell summit is being proposed for April 2013.  It will be held on the Microsoft campus in Redmond.

Preliminary information can be found here

http://powershell.org/summit/

We’d like your help with this   by answering a s very short survey

http://674004.polldaddy.com/s/powershell-summit-na-2013

Your feed back will help us get it right

Thanks

PowerShell v3 download

The download for PowerShell v3 – now know as Windows Management Framework as you get PowerShell, WinRM and new WMI API is now available from

http://www.microsoft.com/en-us/download/details.aspx?id=34595

Versions are available for:

  • Windows 7 SP1
  • Windows 2008 R2 SP1
  • Windows 2008 SP2

No support for Windows 2003, Vista or XP

Finding if the user associated with a profile is logged on

A forum question asked how to find if the user to whom a profile belonged was logged on. There isn’t an easy way as there isn’t an association between the profile and the log on session.

There is a quick and dirty way  though

Get-WmiObject -Class Win32_UserProfile |            
foreach {            
            
$filt =  Split-Path -Path $($_.LocalPath) -Leaf            
$loggedon = $null            
$loggedon = Get-WmiObject Win32_loggedonuser |             
 where {$_.Antecedent -like "*Name=*$filt*"} |             
 select -First 1             
            
$log = $false            
if ($loggedon){$log = $true}            
            
New-Object -TypeName PSObject -Property @{            
 Name = $filt            
 Logged = $log            
}            
}

get the profiles and for each split the Localpath (path to profile) – the leaf holds the user name

Test if you can find an instance of Win32_LoggedOnUser where the Antecedent contains the name

Display data.  Results look like this

Name           Logged

----           ------

DefaultAppPool  False

Richard          True

NetworkService  False

LocalService    False

systemprofile   False

need to filter the system accounts out but I’ll leave that to you

New PowerShell site

If you haven’t found it already I would recommend you visit powershell.org at http://powershell.org/wp/home/.

Its a new location for getting answers to your PowerShell questions.

You will probably recognise some of the people moderating the forums there – Don Jones, Jeff Hicks, Kirk Munro & me among others.

Highly recommended as a PowerShell forum

Windows 8 RTM startup

I was looking at Win32_OperatingSystem today and noticed that the last boot up time wasn’t right

PS> Get-CimInstance -ClassName Win32_OperatingSystem | select LastBootUpTime

LastBootUpTime
--------------
17/08/2012 10:02:11

17 August isn’t right as I know I did a cold start this morning – or at least I think I did!

Windows 8 starts up much faster than Windows 7

Looking at the System event log the last but one entry last night was event id 64 – “The system is entering sleep.”

Looks like using the Shutdown option from Settings – Power only puts the machine to sleep.

I tried using the PowerShell stop-computer cmdlet.

Shutdown took longer than usual. 

I found an entry in the system log stating

“The kernel power manager has initiated a shutdown transition.”

Startup then took much longer than usual

PS> Get-CimInstance -ClassName Win32_OperatingSystem | select LastBootUpTime

LastBootUpTime
--------------
02/09/2012 19:27:41

So looks like use the Settings – Power – Shutdown option to put the machine into a deep sleep and get very quick start up.  Use stop-computer and completely shutdown but have longer startup times.

Question now is does the deep sleep put any drain on the battery for laptops? I’ll try and find out.

Office 2013 and SkyDrive

Office 2013 has the assumption that your SkyDrive is your primary storage area.

Live Essentials supplies an app that allows you to synchronise your PCs with your SkyDrive – it replaces Live Mesh. 

I liked Live Mesh as I could perform peer to peer synchronisation at the folder level.

The new SkyDrive synchronisation only allows a single top level folder and you have to sync through SkyDrive

The interaction between Office 2013 and SkyDrive is not perfect. Office 2013 appears not to understand the SkyDrive and attempts its own synchronisation which doesn’t always work. You are then left with the option to discard your changes or save to another location.

The misunderstandings between SkyDrive and Office 2013 can lead to lost work  - save often!

I haven’t seen as many issues between SkyDrive and Office 2013

This needs to be ironed out before Office 2013 RTMs ideally with a simple option to switch off Office 2013s direct interaction with SkyDrive