Friday, May 8, 2015

Windows 8.1 De-duplication, Mounting VDHX, and Symlinking...oh my

First of all, I realize that this isn't an ideal setup for everyone, but for my home lab I found that this worked pretty well.  My dilemma was such: I had a home lab setup on my desktop PC running Windows 8.1 with Hyper-V on a 500GB SSD but was running out of room quickly.  De-dup is not supported on system or boot volumes, so I had to come up with a different solution.

I borrowed much (most) from Johan Arwidmark over at deploymentresearch.com: http://deploymentresearch.com/Research/Post/406/Beyond-Zip-How-to-store-183-GB-of-VMs-in-a-16-GB-file-using-PowerShell and Teh Wei King's System Center Blog: https://weikingteh.wordpress.com/2013/01/15/how-to-enable-data-deduplication-in-windows-8/

Here's a brief outline of what I'll cover here:

  1. Create VHDX file, mount it to a drive letter, copy files.
  2. Enable Dedup on Windows 8.1.
  3. Dedup the VHDX volume.
  4. Create symlinks to the new location.
  5. Automatically mount VHDX files on boot.
It should be immediately pointed out that de-dup is not officially supported in Windows 8.1, however, when it works, it's really dang awesome!  Additionally, symlinking is really not necessary at all, but it is really nice if you don't want to re-install applications, re-link paths to VHDXs, etc.


    1. Create VHDX file, mount it to a drive letter, copy files.  Create the VHDX file using Create-VHDX.ps1.  It will automatically mount the VHDX to a drive letter.  After mounted, copy your VMs, files, apps, etc. to the new drive.
    2. Enable Dedup on Windows 8.1. First, grab the CAB files to enable the features in Windows 8.1.  Make sure you copy the CAB files to the directory that you plan on running Enable-Win81Dedup.ps1 from or you'll need to specify the full paths to the CABs.
    3. Dedup the VHDX volume using Dedup-VHDX.ps1.  You can check to see how we did by running a Get-DedupStatus command.
    4. Create symlinks by specifying the link and target directories with New-SymbolicLink.ps1.
    5. Automatically mount VHDX files on boot.  There are at least a few ways to mount the VHDX on boot, however I found it difficult to consistently get the same drive letter, which was important since I wanted to create symlinks, so I chose to implement using a scheduled task and diskpart.  You can create the scheduled task to mount the vhdx on boot by running Map-VhdxOnBoot.ps1.
    Okay that's it!  We're done!  I hope you found this to be an useful exercise in how these somewhat unrelated capabilities can be paired together in an interesting way.

    You can grab all of the scripts referenced in this article from here: http://1drv.ms/1zRejwj and the CAB files for enabling the dedup features can be found here: http://1drv.ms/1zReszA

    Thursday, October 2, 2014

    Backup and Restore a WIM from WinPE using DISM

    Backup an image
    1. Boot from WinPE media.
    2. Determine the drive letter to be captured.  This is typically C:,D:, or E:, but it can vary depending on which devices are connected to the system.
    3. There are a few choices for where to back up the image, but my preference is to back it up to a network drive.  To do this, run the following command: 
      • Net use Z: \\<ServerName>\<DestinationPath>\
      • You should see “The command completed successfully” if it works correctly.  Remember, you need to have write permissions to this directory in order to save the image to it, so you should be prompted for credentials to connect to the share.
    4. DISM.exe should already be in the path environment variable in WinPE 5.0, so you can call the DISM executable from pretty much anywhere.
      • DISM.exe /Capture-Image /ImageFile:Z:\capture.wim /CaptureDir:E:\
      • Where Z: is the path to which you want to save the image and E: is the path to the partition with Windows installed.
      • If the drive contains much data, it will take an amount of time proportional the amount of data and the throughput of your network, USB, or eSATA connection.  Be patient
    Restore an image
    To restore an image to a new machine or a new drive, it is a very similar process, only the command in step 4 really changes.
    1. Boot from WinPE media.
    2. Determine the drive letter to restore the image.  This is typically C:,D:, or E:, but it can vary depending on which devices are connected to the system.
    3. If you used a network path to backup your image, you must re-map the drive again.  To do this, run the following command.
      • Net use Z: \\<ServerName>\<DestinationPath>\
      • You should see “The command completed successfully” if it works correctly.  Remember, you need to have write permissions to this directory in order to save the image to it, so you should be prompted for credentials to connect to the share.
    4. DISM.exe should already be in the path environment variable in WinPE 5.0, so you can call the DISM executable from pretty much anywhere.
      • DISM.exe /Apply-Image /ImageFile:Z:\install.wim /Index:1 /ApplyDir:E:\
      • Where Z: is the path where the backup image is stored and E: is the path of the partition to restore the image.
      •  If the image contains much data, it will take an amount of time proportional the amount of data and the throughput of your network, USB, or eSATA connection.  Be patient!

    Wednesday, October 1, 2014

    Create a New AD and SCCM 2012 User Collection with PowerShell

    Function New-SCCMUserCollection {
    PARAM (
    [Parameter(Mandatory = $true)] $ADCollectionName,
                    [Parameter(Mandatory = $true)] $CMCollectionName,
    $limitingCollection = "All Users",
    # Customize the $path appropriately for your environment.
    $path = "OU=Application Deployment,OU=Groups,DC=<YourDomain>,DC=<YourNamespace>",
    $description = "Application Deployment Group",
    # Customize your domain name in the query.
    $queryExpression = "select SMS_R_USER.ResourceID,SMS_R_USER.ResourceType,SMS_R_USER.Name,SMS_R_USER.UniqueUserName,SMS_R_USER.WindowsNTDomain from SMS_R_User where SMS_R_User.SecurityGroupName = '<YourDomain>\\$($ADCollectionName)'",
    $ServerName = "<YourServerName>",
    $SiteCode = "<YourSiteCode"
    )
    # Get a reference object for grabbing the RefreshSchedule property
            # Use an existing collection as a template to replicate the RefreshSchedule.
    $refreshSchedule = (Get-CMDeviceCollection -Name "7zip").RefreshSchedule[0]
    $ruleName = $CMCollectionName

    # Create AD Security Group
    New-ADGroup -Name $ADCollectionName -SamAccountName $ADCollectionName -GroupCategory Security -GroupScope Universal -DisplayName $ADCollectionName -Path $path -Description $description -Verbose

    # Create SCCM Collection
    New-CMUserCollection -Name $CMCollectionName -LimitingCollectionName $limitingCollection -Verbose -RefreshSchedule $refreshSchedule -RefreshType 2

    # Add collection rule
        $CollectionName = Get-CMUserCollection -Name $CMCollectionName
        Add-CMUserCollectionQueryMembershipRule -CollectionId $CollectionName.CollectionID -RuleName $ruleName -QueryExpression $queryExpression -Verbose
    }

    # Import the Configuration Manager 2012 Module
    Import-Module "C:\Program Files (x86)\ConfigMgr2012\bin\ConfigurationManager.psd1"
    # Set location the primary site code
    Set-Location <YourSiteCode>:
    Import-Module ActiveDirectory

    # Edit this variable to reflect the desired AD Security Group Names
    $ADCollectionName = "Test User Collection"

    # Do not edit this variable unless it is a special circumstance.
    $CMCollectionName = "$ADCollectionName - User"

    # Usage: New-SCCMUserCollection -ADCollectionName $ADCollectionName -CMCollectionName $CMCollectionName

    Tuesday, September 2, 2014

    DaRT 2013 in SCCM 2012

    Integrating DaRT from MDOP 2013 is a great way to troubleshoot and monitor operating system deployments remotely.  Deploymentresearch.com has a great article for how to configure this in your environment.
    http://www.deploymentresearch.com/Research/tabid/62/EntryId/131/Adding-DaRT-8-1-from-MDOP-2013-R2-to-ConfigMgr-2012-R2.aspx

    Friday, August 29, 2014

    Generic CustomSettings.ini Files for SCCM, MDT integrated, Task Sequences

    Generic CustomSettings.ini Files for SCCM, MDT integrated, Task Sequences

    Example CustomSettings.ini files for SCCM, MDT integrated, task sequences can be found here.

    Configure Dell BIOS from WinPE

    Configure Dell BIOS from WinPE

    To start off, I should clarify that I typically use SCCM Task Sequences with MDT integration.  The following scenario utilizes SCCM 2012 R2 with MDT 2013 integration.


    1. Download and install the Dell Client Configuration Toolkit (CCTK) from Dell's website: http://www.dell.com/support/home/us/en/04/Drivers/DriversDetails?driverId=6HCTN
    2. From the installation directory, typically C:\Program Files (x86)\Dell\CCTK, grab X86 and X86_64 folders and create an empty package (no programs).
    3. Additionally, add CCTK-default.cmd and show-cctkerrors.vbs to the root of your package folder, we'll be utilizing this in a task sequence step.  These files were originally authored by windowsmasher: http://windowsmasher.wordpress.com/2013/01/21/sccm-2012-generic-multi-platform-dell-cctk-bios-settings/.  Thank you!  I've made my own customization to the cmd file to better suite my needs.  Created a config subfolder in the CCTK package and drop Multi-Platform_Generic.ini there.  You can find the files you need here.  The final folder structure should look like this: 
      • root\X86\<all X86 files from CCTK>
      • root\X86_64\<all X86_64 files from CCTK>
      • root\config\Multi-Platform_Generic.ini
    4. Edit your OSD Task Sequence and insert a new folder Configure Dell BIOS.  I prefer to insert this at the Preinstall phase of the task sequence, although it technically can be applied anytime before the Apply Operating System image step in the task sequence.  This is because we reconfigure the SATA operating mode to the highest level that the BIOS is capable of, RAID On, AHCI, ATA, respectively.

    5. You must also remember to create evaluations in the options of this new folder to ensure that the PC is actually running in WinPE and that the Manufacturer is Dell.
    6. The next step is optional, but recommended for easily troubleshooting BIOS configuration issues.  Create a step called Connect to Network Drive.  This drive will be used for dumping log files in a subsequent step.
    7. After optionally mapping a network drive, it's time to perform the actual configuration.  It's recommended that you read through the cmd file and make appropriate modifications to best suite your environment.
    8. We must restart the computer to have the BIOS settings take effect.  This is particularly important for the SATA operation to ensure that the appropriate storage drivers are installed.  Make sure you reboot to WinPE, there is no operating system installed yet.
    9. After rebooting, we need to re-load the toolkit package and run the gather step again.