Session recordings from TechEd New Zealand 2014 are live!

The two sessions I delivered at TechEd New Zealand 2014 are now live and available on MSDN Channel 9:

Session: Deep Dive – Deploying and Managing Windows To Go

Session: Automated Compliance, Auditing and Remediation for the Enterprise Datacenter

As always, it was great to attend TechEd New Zealand – the event organisers and track owners did a great job as they always do, and the audiences are always engaged and ready to skewer an unsuspecting presenter with difficult questions :-)

Create an OS Deployment Task Sequence in Configuration Manager 2012 with PowerShell

This code is designed to create the framework for the Windows 8.1 OSD Task Sequence used in Chapter 11 of “Learn ConfigMgr 2012 in a Month of Lunches“.

The PowerShell cmdlet doesn’t perform the full amount of customisation which the reader does in the book’s lab environment, but it sets up the structure of the Task Sequence quite well, leaving very little post-script customisation to perform.

You can download the script directly from http://www.jamesbannanit.com/wp/files/manning/CMTaskSequence.zip.

# Define Configuration Manager variables
 
$CMSiteCode = 'P01'
$CMSiteServer = 'LAB-CM01.mol.sccmlab.net'
$CMNameSpace = "root\SMS\site_$CMSiteCode"
 
# 1.0 Get Deployment Objects
 
$BootImageID = (Get-CMBootImage -Name 'Custom Boot Image (x64)').PackageID
$OSImageID = (Get-CMOperatingSystemImage -Name 'Windows 8.1 x64 Enterprise Gold').PackageID
$ClientPackageID = (Get-CMPackage -Name 'Configuration Manager Client Package').PackageID
 
 
# 1.1 Create Task Sequence
 
New-CMTaskSequence -InstallOperatingSystemImageOption `
  -TaskSequenceName 'Deploy Windows 8.1 x64 Enterprise' `
  -BootImagePackageId $BootImageID `
  -OperatingSystemImagePackageId $OSImageID `
  -OperatingSystemImageIndex '1' `
  -ClientPackagePackageId $ClientPackageID `
  -JoinDomain DomainType `
  -DomainName 'mol.sccmlab.net' `
  -DomainAccount 'MOL\CM_JD' `
  -DomainPassword 'P@ssw0rd' `
  -DomainOrganizationUnit 'LDAP://OU=Workstations,OU=SCCMR2Lab,DC=mol,DC=sccmlab,DC=net' `
  -PartitionAndFormatTarget $true `
  -LocalAdminPassword 'P@ssw0rd'

Import Drivers into Configuration Manager 2012 with PowerShell

This code is designed to import the device drivers as per Chapter 11 in “Learn ConfigMgr 2012 in a Month of Lunches“.  The code does the following:

  1. Creates and distributes a new Driver Package
  2. Checks to see whether the Administrative Categories already exist, and creates them if they don’t
  3. Finds all the *.INF driver files in the source location
  4. Imports the drivers, assigning them to the Driver Package and the Administrative Categories

You can download the code from http://www.jamesbannanit.com/wp/files/manning/CMDriverImport.zip.

# Define Configuration Manager variables
 
$CMSiteCode = 'P01'
$CMSiteServer = 'LAB-CM01.mol.sccmlab.net'
$CMNameSpace = "root\SMS\site_$CMSiteCode"
$DriverPackageName = 'Dell Latitude E6530 – Windows 8.1 x64 - A01'
$DriverPackageSource = '\\lab-cm01\Sources\Driver Packages\Dell Latitude E6530 - Windows 8.1 x64 - A01'
$DriverSource = '\\lab-cm01\Sources\Drivers\Dell Latitude E6530\Windows 8.1 x64'
$DriverCategoryName01 = 'Windows 8.1 x64'
$DriverCategoryName02 = 'Dell Latitude E6530'
 
# 1.0 Create Driver Package
 
New-CMDriverPackage -Name $DriverPackageName -Path $DriverPackageSource -Verbose
 
$DriverPackage = Get-CMDriverPackage -Name $DriverPackageName
 
Start-CMContentDistribution -DriverPackageName $DriverPackage.Name -DistributionPointName $CMSiteServer -Verbose
 
# 1.1 Create Administrative Categories
 
If ((Get-CMCategory -Name $DriverCategoryName01) -eq $null) {
  New-CMCategory -CategoryType DriverCategories -Name $DriverCategoryName01
}
 
$DriverCategory01 = Get-CMCategory -Name $DriverCategoryName01
 
If ((Get-CMCategory -Name $DriverCategoryName02) -eq $null) {
  New-CMCategory -CategoryType DriverCategories -Name $DriverCategoryName02
}
 
$DriverCategory02 = Get-CMCategory -Name $DriverCategoryName02
 
# 1.2 Build Category array
 
$DriverCategories = @()
$DriverCategories += $DriverCategory01
$DriverCategories += $DriverCategory02
 
# 1.3 Get Drivers
 
Set-Location C:
 
$Drivers = Get-ChildItem -Path $DriverSource -Include *.inf -Recurse
 
Set-Location ($CMSiteCode + ':')
 
# 1.4 Import Drivers
 
foreach ($driver in $drivers){
  Import-CMDriver -UncFileLocation $Driver.FullName `
    -DriverPackage $DriverPackage `
    -EnableAndAllowInstall $true `
    -AdministrativeCategory $DriverCategories `
    -ImportDuplicateDriverOption AppendCategory `
    -ErrorAction SilentlyContinue `
    -Verbose
    }

Create a Package in ConfigMgr 2012 R2 with PowerShell

This PowerShell code is designed to create a new Configuration Manager Package for Notepad++ as well as an installation Program for the new Package, as per Chapter 8 in “Learn ConfigMgr 2012 in a Month of Lunches“.

While the code is specific for the lab environment, it will work for any Program in Configuration Manager 2012 R2.

# Define Configuration Manager variables
 
$CMSiteCode = 'P01'
$CMSiteServer = 'LAB-CM01.mol.sccmlab.net'
$CMNameSpace = "root\SMS\site_$CMSiteCode"
$PackageName = 'Notepad++ 6.6.9'
 
# 1.0 Create new Package
 
New-CMPackage -Name $PackageName -Path '\\lab-cm01\Sources\Software\Notepad++\6.5.2'
 
# 1.1 Create new Program
 
New-CMProgram -PackageName $PackageName `
  -StandardProgramName 'Install - Notepad++ 6.6.9' `
  -CommandLine 'npp.6.6.9.Installer.exe /S' `
  -RunType Hidden `
  -RunMode RunWithAdministrativeRights `
  -UserInteraction $false `
  -ProgramRunType WhetherOrNotUserIsLoggedOn `
  -DriveMode RenameWithUnc

Create an Application in ConfigMgr 2012 R2 with PowerShell

This PowerShell code is designed to create a new Configuration Manager Application for Paint.NET with two deployment types (32-bit and 64-bit) as per Chapter 7 of “Learn ConfigMgr in a Month of Lunches“.

The deployment types are based on MSIs with the uninstall string and detection method auto-populated, so there’s not much configuration which needs to be done.

# Define Configuration Manager variables
 
$CMSiteCode = 'P01'
$CMSiteServer = 'LAB-CM01.mol.sccmlab.net'
$CMNameSpace = "root\SMS\site_$CMSiteCode"
$ApplicationName = 'Paint.NET v3.5.11'
 
# 1.0 Create new Application
 
New-CMApplication -Name $ApplicationName -LocalizedApplicationName $ApplicationName
 
$Application = Get-CMApplication -Name $ApplicationName
 
# 1.1 Create x64 Deployment Type
 
Add-CMDeploymentType -ApplicationName $Application.LocalizedDisplayName `
  -AutoIdentifyFromInstallationFile `
  -ForceForUnknownPublisher $true `
  -InstallationFileLocation '\\LAB-CM01\Sources\Software\Paint.NET\3.5.11\x64\PaintDotNet.x64.msi' `
  -MsiInstaller `
  -DeploymentTypeName 'Paint.NET v3.5.11 (x64) - Windows Installer (*.msi file)'
 
# 1.2 Create x86 Deployment Type
 
Add-CMDeploymentType -ApplicationName $Application.LocalizedDisplayName `
  -AutoIdentifyFromInstallationFile `
  -ForceForUnknownPublisher $true `
  -InstallationFileLocation '\\lab-cm01\Sources\Software\Paint.NET\3.5.11\x86\PaintDotNet.x86.msi' `
  -MsiInstaller `
  -DeploymentTypeName 'Paint.NET v3.5.11 (x86) - Windows Installer (*.msi file)'