How to: Initialize, format and label disks during OSD Task Sequence in SCCM 2012 R2

During a task seuence in Microsoft SCCM 2012 R2, the operating system and applications are installed on the C: drive in most situations. But in some deployments, you definitely want to create more disks. For example, you want to create a D: and E: partition for storing some other data. Maybe for Microsoft SQL or Exchange installation, databases, logfiles or just some other data.

The following script will do all these steps for you during the task sequence. The script initialize, format, partition and label the disks for you….fully automated! 🙂

## Set CD-ROM from E: to X:
Set-WmiInstance -InputObject ( Get-WmiObject -Class Win32_volume -Filter "DriveLetter = 'E:'" ) -Arguments @{DriveLetter='X:'}

$disks = Get-Disk | measure
If($disks.Count -eq 2)
{
## Initialize all new disks
Initialize-Disk 1
## Format and rename disks
Get-Disk | where {$_.Number -eq "1"} | New-Partition -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel Data -Confirm:$false
## Set drive letters (D: - Data, E: - Backup)
Get-Disk | where {$_.Number -eq "1"} | Get-Partition | where {$_.PartitionNumber -eq 2} | Set-Partition -NewDriveLetter D
}
elseif($disks.Count -eq 3)
{
## Initialize all new disks
Initialize-Disk 1
Initialize-Disk 2
## Format and rename disks
Get-Disk | where {$_.Number -eq "1"} | New-Partition -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel Data -Confirm:$false
Get-Disk | where {$_.Number -eq "2"} | New-Partition -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel Backup -Confirm:$false
## Set drive letters (D: - Data, E: - Backup)
Get-Disk | where {$_.Number -eq "1"} | Get-Partition | where {$_.PartitionNumber -eq 2} | Set-Partition -NewDriveLetter D
Get-Disk | where {$_.Number -eq "2"} | Get-Partition | where {$_.PartitionNumber -eq 2} | Set-Partition -NewDriveLetter E
}
else
{
exit
}
exit

The script first checks how many disks are attached to the server.
If there is only one disk attached, you’ll have only a C: drive available after the deployment.
If there are 2 disks attached, you’ll have a C: and D: drive avalailable after the deployment.
If there are 3 disks attached, you’ll have a C:, D: and E: drive available after the deployment.

The CD-ROM drive will alse changed from E: to X:.

2015-12-18_12h30_44    2015-12-18_12h32_27    2015-12-18_12h32_52

2015-12-18_12h34_31    2015-12-18_12h37_51    2015-12-18_12h41_05

2015-12-18_12h41_43

How to: Enable RDP during Task Sequence with SCCM 2012 R2

I quiet often receive the question how to enable Remote Desktop (RDP) access on a server during a task sequence in SCCM 2012 or 2012 R2. Because by default RDP is not enabled, it could be realy handy to enable RDP access to control your server remotely. There’re a whole bunch of tools to manage your server(s) remotely, but still RDP could be ncessary.

1.) Create a new package with the source location to your script directory.
2.) Create a new package with a program and use the following command:
Powershell.exe -ExecutionPolicy Unrestricted -NoProfile -File Enable-RDP.ps1
3.) The PowerShell script ‘Enable-RDP.ps1’ contains the following code. See in this post below.
4.) Insert the script in your task sequence

##
## Enable RDP
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -Value 0
##
## Enable Firewall Rule
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
##
## Enable RDP Authentication
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 0

2015-11-27_09h03_02    2015-11-27_09h03_21    2015-11-27_09h34_03

SCCM 2012 R2 SP1 CU1….Why are my task sequences not visible?

This week I’ve upgraded a SCCM 2012 R2 environment to Service Pack 1 with update CU1. After the upgrade, I noticed that not all my task sequences (deployment) where available after PXE boot. Why is that? Is this a ‘new feature’ or just a ‘bug’? After some Troubleshooting I’ve figured out that there’s a strange thing in my deployments!

As you can see in my example I’ve created a collection with 3 deployments active. After PXE boot a virtual machine, only the first deployment is available?!?! :S The other two deployments are also active, but not available…

When we go to the properties of the other two deployments, and change the schedule 1 day back in the time, the deployment became available!! Very strange behavior, but this is the only ‘solution’ I’ve figured out!

2015-10-05_21h47_55    2015-10-05_21h48_48    2015-10-05_21h50_01

2015-10-05_21h50_49    2015-10-05_21h52_01    2015-10-05_21h52_07

2015-10-05_21h52_33    2015-10-05_21h52_50    2015-10-05_21h53_00

2015-10-05_21h54_37    2015-10-05_21h54_43    2015-10-05_21h55_05

Configuration Manager 2012 R2 – How to: Move a Distribution Point Content Library to another drive

Today I had to move the library of the Distribution Point to another partition, because it was placed on the wrong partition during the install.

During the installation of ConfigMgr 2012 R2 (or ealier), you can place a file “no_sms_on_drive.sms” on the partitions that should be ignored for placing the library on.
In this environment there’s a C:, D: and E: drive. The C: partition is only used for the operating system. The D: drive is used for the installation of
ConfigMgr 2012 R2, SQL 2012 and the remote installation folder of WDS. The E: drive is used for the sources, images, ISO’s and the library of the Distribution Point.

So I want to move the library from the D: to the E: partition. First you’ve to download the “System Center 2012 R2 Configuration Manager Toolkit”. http://www.microsoft.com/en-us/download/details.aspx?id=36213

1.) Open REGEDIT and navigate to HKLM\SOFTWARE\Microsoft\SMS\DP and look for the registry key
ContentLibraryPath” and “ContentLibUsableDrives
2.) When you open Windows Explorer and browse to the D: drive, you’ll see the library folders
SCCMContentLib
SMSPKG
SMSPKGD$
SMSPKGSIG
SMSSIG$
These folders we want to move to the E: drive
3.) Open the command prompt and navigate to C:\Program Files (x86)\ConfigMgr 2012 Toolkit R2\ServerTools\”
4.) Use the following command to move the Library content from D: to E:
ContentLibraryTransfer.exe -SourceDrive D -TargetDrive E > C:\TransferContentLibrary_log.txt
5.) Start CMTrace.exe and open the logfile “C:\TransferContentLibrary_log.txt” to watch the progress of the library move
6.) After a few hours, depending on the size of your library content, the move action is done
7.) pen REGEDIT and navigate to HKLM\SOFTWARE\Microsoft\SMS\DP and look for the registry key
ContentLibraryPath” and “ContentLibUsableDrives
Now you’ll see only the E: drive for the Library placement
8.) I’ve have created the file “no_sms_on_drive.sms” on the C: and D: drive

2015-03-12_10h18_06    2015-03-12_10h18_58    2015-03-12_10h19_13

2015-03-12_10h19_32    2015-03-12_10h21_23    2015-03-12_10h45_29

2015-03-12_10h45_51    2015-03-12_10h46_26    2015-03-12_10h46_59

2015-03-12_11h54_26    2015-03-12_11h55_02    2015-03-12_11h57_32

How to: View all packages within your ConfigMgr 2012 R2 environment

When you have a Microsoft ConfigMgr 2012 or 2012 R2 environment, you definitely have a lot of packages and applications. This could be: tools, scripts, client packages, boot images, ISO’s, WIM files, different software applications, etc. When you have no idea where all these source files are located, you can execute a query within your SQL environment.

You can generate an overview of all your packages, with the package ID, description, name, source location, version, etc. Very helpfull and it saves you alot of time!!

1.) Open the Microsoft SQL Server Managent Studio
2.) Login with a user that has enough rights to execute queries
3.) Select the ConfigMgr database (in my example CM_PS1)
4.) Select “New Query”
5.) Type “SELECT * from v_Package”
6.) Select “Execute” or press F5 on your keyboard
7.) Now you’ll see a list off all the packages within your ConfigMgr 2012 environment
8.) Navigate to the table “PkgSourcePath”
9.) Here are your source files locates of all the different packages

2015-02-19_11h03_04    2015-02-19_11h03_54    2015-02-19_11h04_36

2015-02-19_11h05_03    2015-02-19_11h16_42

How to: Deploy packages using collection variable with ConfigMgr 2012 R2

During a OS deployment you don’t want to deploy all your packages and software to every workstation. You can deploy the software after a full OS deployment, but you can also deploy packages during the OSD using collection variables. Now it is possible to deploy packages only if a specific machine is a member of a collection. This collection can be query based, for example OU membership or Active Directory security group, or it can be static (direct membership).

In this example I’ve created a realy simple deployment, Adobe Reader 11.0. I’ve two virtual machines, SCWIN81-01 and SCWIN81-02. Both machines are members of the collection “Deploy – Windows 8.1 Enterprise x64”, where the task sequence is deployed on. Machine SCWIN81-01 is also member of the collection “Install – Adobe Reader 11.0”. This collection has a limited collection of “Deploy – Windows 8.1 Enterprise x64”. Both machines are deployed on the same time, the only difference is that machine SCWIN81-01 has Adobe Reader 11.0 installed and machine SCWIN81-02 not. Why……based on the collection variable during the OSD 🙂

1.) First create the collections
2.) Make the specific machines members of the right collections (query based or direct membership)
3.) Open the properties of the collection “Install – Adobe Reader 11.0” and navigate to the “Collection Variables” tab
4.) Add one or more variables with some values. In this example the variable is “APP-AdobeReader” with the value “Yes”
5.) Open the task sequence and add a package installation step
6.) Add the package with the program and navigate to the “Options” tab
7.) Select “Add Condition” and select “Task Sequence Variable”
8.) Enter the collection variable you’ve created earlier with the same value. In my example:
Task Sequences Variable APP-AdobeReader equals “Yes”
9.) Select “Apply” and close the task sequence.
10.) Start the OSD on both machines and wait until the installation is done!
11.) Watch the differences between both machines, if everything is okay, one machine has Adobe Reader installed and the other not.

This is an extremely powerfull thing within ConfigMgr, and really helpfull is some scenario’s. For example VDI golden image deployments or hybrid environments with laptops/desktops or multiple organizations using one ConfigMgr environment. One main reason could be consolidation in task sequences. If you want, there should be only one task sequence for all you different deployments. This is why I’m loving collection varaibles! 🙂

2014-12-22_15h45_33    2014-12-22_15h46_26    2014-12-22_15h46_48

2014-12-22_15h47_23    2014-12-22_15h49_46    2014-12-22_15h50_15

2014-12-22_15h50_37    2014-12-22_15h51_16    2014-12-22_15h51_58

How to: Apply Windows updates during OSD with ConfigMgr 2012 R2

During a OS deployment with ConfigMgr 2012 R2, you definitely want to apply the latest Windows updates and patches, for example with Windows Server Update Service (WSUS). You can also integrate WSUS within ConfigMgr 2012 R2, but in this example WSUS is not integrated!!

This example is also very usefull to create a fully patches golden image in ConfigMgr 2012 R2 (Build & Capture). After the task sequence you’ve a fully patches Windows 8.1 machine that you can use for example VDI environments.

1.) Fist open your task sequence
2.) Create a new computer group “Desktops” within the WSUS console (or choose another name, for exmaple: servers, laptops, etc.)
3.) Add a custom group within the task sequence
4.) Add the following steps in your task sequence
Run Command Line:
reg ADD “HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate” /v WUServer /t REG_SZ /d http://wsus01.cloud.local:8530 /f
Run Command Line:
reg ADD “HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate” /v WUStatusServer /t REG_SZ /d http://wsus01.cloud.local:8530 /f
Run Command Line:
reg ADD “HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate” /v TargetGroup /t REG_SZ /d “Desktops” /f
Run Command Line:
reg ADD “HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate” /v TargetGroupEnabled /t REG_DWORD /d 1 /f
Run Command Line:
reg ADD “HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v UseWUServer /t REG_DWORD /d 1 /f
Run Command Line:
wuauclt.exe /resetauthorization /detectnow
5.) Don’t forget to set the name of your WSUS server and computer group in the commands above!
6.) Create a new package in ConfigMgr 2012 R2 with the following two files in it, located in the MDT 2013 deployment share directory
ZTIUtility.vbs
ZTIWindowsUpdate.wsf
7.) Don’t create a program in this package, but you only have to distribute it to the distribution point(s)
8.) Add a new step “Run Command Line” to the task sequence with the following command:
cscript.exe ZTIWindowsUpdate.wsf
Select the package where the source files are located
9.) Deploy the task sequence to your client collection!

COAU_01    COAU_02    COAU_03

COAU_04    COAU_05    COAU_06

COAU_07    COAU_08    COAU_09

COAU_10    COAU_11    COAU_12

How to: Disable first sign-in animation in Windows 8.1 using ConfigMgr 2012 R2

When a user login the very first time on a Windows 8 of 8.1 machine, they will see a “animation” with some helpful tips. During this stage the userprofile is being created and prepared. While the first sign-in animation may be helpful to new users to see, but it slows down the logintimes. So let’s turn this animation off using ConfigMgr 2012 R2.

1.) Open your task sequence
2.) Add a action “Run Command Line” after Setup Windows and ConfigMgr
3.) Copy and paste the following command line:
reg ADD “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System” /v EnableFirstLogonAnimation /t REG_DWORD /d 0 /f
4.) Give it the value 0 to disable and 1 to enable
5.) Deploy your task sequence to a collection of devices

FRA_01    2014-12-22_10h44_09    2014-12-22_10h44_50