Hot to use PowerShell to manage System Center Configuration Manager

The easiest way is by launching the Configuration Manager console. In the upper left corner, there’s a blue rectangle. Click the white arrow in the blue rectangle, and choose Connect via Windows PowerShell.

cm

Now, you need to import the Configuration Manager module by using the Windows PowerShell Import-Module cmdlet. To import the Configuration Manager module, you will have to specify the path to the Configuration Manager module or change to the directory that contains the module. Here, we’re going to change to the module’s directory.

PS C:\>

PS C:\> CD ‘C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager’

PS C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager>

Then import the module;

Import-Module .\ConfigurationManager.psd1

To run the Configuration Manager cmdlets, you need to switch the path to the Configuration Manager site.

PS C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager>CD MSN

MSN – is my site code

PS MSN:\>

Confirm that the Configuration Manager module has been loaded by using the cmdlet below;

PS MSN:\> Get-CMSite

BuildNumber : 7958

Features : 0000000000000000000000000000000000000000000000000000000000000000 InstallDir : C:\Program Files\Microsoft Configuration Manager

Mode : 0

ReportingSiteCode :

RequestedStatus : 110

ServerName : cm1.company.pri

SiteCode : MSN

SiteName : MSN pri site

Status : 1

TimeZoneInfo : 000001E0 0000 000B 0000 0001 0002 0000 0000 0000 00000000 0000 0003 0000 0002 0002 0000 0000 0000 

Type : 2

Version : 5.00.7958.1000

Advertisements

System Center Configuration Manager SCCM Collection Queries

Some of the useful queries we used and still being used;

Client Collections

Collection for all Workstations.

  select

SMS_R_SYSTEM.ResourceID, SMS_R_SYSTEM.ResourceType, SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SMSUniqueIdentifier,

SMS_R_SYSTEM.ResourceDomainORWorkgroup, SMS_R_SYSTEM.Client

from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like

“%workstation%”

 

Collection of all Windows 10 clients.

  select

SMS_R_SYSTEM.ResourceID, SMS_R_SYSTEM.ResourceType,

SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SMSUniqueIdentifier,

SMS_R_SYSTEM.ResourceDomainORWorkgroup, SMS_R_SYSTEM.Client from

SMS_R_System

where SMS_R_System.OperatingSystemNameandVersion like “%workstation 10.0%”

Collection of all Windows 8.1 clients.

  select

SMS_R_SYSTEM.ResourceID, SMS_R_SYSTEM.ResourceType, SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SMSUniqueIdentifier,

SMS_R_SYSTEM.ResourceDomainORWorkgroup, SMS_R_SYSTEM.Client from

SMS_R_System

where SMS_R_System.OperatingSystemNameandVersion like “%workstation 6.3%”

Collection of all Windows 8 clients.

This query need to be limited to the All Workstations collection to work. If not it will also have Windows Server 2012 members as they share the same version number.

  select

SMS_R_SYSTEM.ResourceID, SMS_R_SYSTEM.ResourceType, SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SMSUniqueIdentifier,

SMS_R_SYSTEM.ResourceDomainORWorkgroup, SMS_R_SYSTEM.Client from

SMS_R_System

where SMS_R_System.OperatingSystemNameandVersion like “%workstation 6.2%”

 

Collection of all Windows 7 clients.

This query need to be limited to the All Workstations collection to work. If not it will also have Windows Server 2008 R2 members as they share the same version number.

  select

SMS_R_SYSTEM.ResourceID, SMS_R_SYSTEM.ResourceType, SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SMSUniqueIdentifier,

SMS_R_SYSTEM.ResourceDomainORWorkgroup, SMS_R_SYSTEM.Client from

SMS_R_System

where SMS_R_System.OperatingSystemNameandVersion like “%workstation 6.1%”

 

Collection for all Servers.

  select

SMS_R_SYSTEM.ResourceID, SMS_R_SYSTEM.ResourceType, SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SMSUniqueIdentifier,

SMS_R_SYSTEM.ResourceDomainORWorkgroup, SMS_R_SYSTEM.Client

from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like

“%server%”

 

Collection of all Windows 2012 R2 Servers.

  select

SMS_R_SYSTEM.ResourceID, SMS_R_SYSTEM.ResourceType, SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SMSUniqueIdentifier,

SMS_R_SYSTEM.ResourceDomainORWorkgroup, SMS_R_SYSTEM.Client from

SMS_R_System

where SMS_R_System.OperatingSystemNameandVersion like “%Server 6.3%”

 

Collection of all Windows 2012 Servers.

  select SMS_R_SYSTEM.ResourceID, SMS_R_SYSTEM.ResourceType, SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SMSUniqueIdentifier,

SMS_R_SYSTEM.ResourceDomainORWorkgroup, SMS_R_SYSTEM.Client from

SMS_R_System

where SMS_R_System.OperatingSystemNameandVersion like “%Server 6.2%”

 

Collection of all Windows 2008 R2 Servers.

  select SMS_R_SYSTEM.ResourceID, SMS_R_SYSTEM.ResourceType, SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SMSUniqueIdentifier,

SMS_R_SYSTEM.ResourceDomainORWorkgroup, SMS_R_SYSTEM.Client from

SMS_R_System

where SMS_R_System.OperatingSystemNameandVersion like “%Server 6.1%”

 

Collection of all Domain Controllers.

This query requires that the config manager client is installed and hardware inventory is turned on.

  select *  from  SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId

where SMS_G_System_COMPUTER_SYSTEM.Roles like “%Domain_Controller%”

All Hewlet-Packard Systems

  select

SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,

SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,

SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client

from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on

SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId

where SMS_G_System_COMPUTER_SYSTEM.Manufacturer like “Hewlett-Packard%”

or SMS_G_System_COMPUTER_SYSTEM.Manufacturer like “HP%”

All Physical Systems

  select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,

SMS_R_SYSTEM.SMSUniqueIdentifier,

SMS_R_SYSTEM.ResourceDomainORWorkgroup,

SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_SYSTEM_ENCLOSURE on SMS_G_System_SYSTEM_ENCLOSURE.ResourceID = SMS_R_System.ResourceId

where SMS_G_System_SYSTEM_ENCLOSURE.ChassisTypes = “23” or

SMS_G_System_SYSTEM_ENCLOSURE.ChassisTypes = “17”

 

SQL Server Collection Query

select SMS_R_System.ResourceId, SMS_R_System.ResourceType, SMS_R_System.Name, SMS_R_System.SMSUniqueIdentifier, SMS_R_System.ResourceDomainORWorkgroup, SMS_R_System.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_ADD_REMOVE_PROGRAMS_64 on SMS_G_System_ADD_REMOVE_PROGRAMS_64.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like “Microsoft SQL Server 200%” or SMS_G_System_ADD_REMOVE_PROGRAMS_64.DisplayName like “Microsoft SQL Server 20%”

 

All Windows Workstations

Select

SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like ‘Microsoft Windows NT%Workstation%’

 

All Systems with HyperV Role

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System  inner join SMS_G_System_SERVICE on SMS_G_System_SERVICE.ResourceID = SMS_R_System.ResourceId  where SMS_G_System_SERVICE.DisplayName like “Hyper-V Virtual Machine Management”

 

SCCM All Laptops Collection

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_SYSTEM_ENCLOSURE on SMS_G_System_SYSTEM_ENCLOSURE.ResourceID = SMS_R_System.ResourceId where   SMS_G_System_SYSTEM_ENCLOSURE.ChassisTypes in ( “8”, “9”, “10”, “14” )

 

 

 

 

 

Configuring the vDisk access mode in PVS

vDiskAccessMode

 

  • Standard Image – Select this mode if a vDisk is shared by multiple target devices (write-cache options enabled).
  • Private Image – Select this mode if a vDisk is only used by a single target device (read/write access is enabled).

accessMode

Standard Image mode

Standard Image mode allows multiple target devices to stream from a single vDisk image at the same time. This reduces the amount of vDisk management and reduces storage requirements.

When a vDisk is configured to use Standard Image mode, it is set to read-only mode. Each target device then builds a write cache to store any writes the operating system needs to make. There are several write-cache options available. Because the vDisk is read-only, each time a target device boots, it always boots from a ‘clean’ vDisk. If a machine becomes infected with a virus or spyware, the target device only needs to reboot the image.

When updates are made to a vDisk in Standard Image mode, changes against the base vDisk image are captured in a differencing disk file (.avhdx), resulting in a new version of the base image. Each new version remains directly associated with the base image. Versioning allows for the updates captured in the differencing disk to be staged (Maintenance, Test, Production) before those changes become available to Production devices. If issues are encountered with a version, that version can simply be reverted.

Although each target device uses the same vDisk, Provisioning Services personalizes the streamed image for each target device, providing the information needed to ensure the device is uniquely identifiable on the network. You can also specify additional personality settings for each device: you can store application-specific values in the database and retrieve the target device’s unique value as the device loads.

Private Image mode

A vDisk that is in Private Image mode closely models how a computer uses a regular hard drive. That is, only one target device can use a Private Image vDisk at a time.

The following illustrates Private Image vDisks (read/write) that are each assigned to a single production device, and a Standard Image vDisk (read-only) that is assigned to and shared by a collection of production devices. For Standard Image vDisks, write cache options include cache on server disk, on a device’s hard disk drive, or in the device’s RAM.

 

To configure the vDisk mode and any applicable write cache destination

Note: Only write cache destinations that are supported for Standard access mode appear enabled.
  1. On the Console, right-click on the vDisk for which you want to configure the vDisk access mode, then select vDisk Properties. The vDisk Properties dialog appears.
  2. Click on the General tab, then select the image mode (Standard or Private) that applies to this vDisk from the Access Mode drop-down list.
  3. If Standard image was selected, from the cache destination drop-down list, select the appropriate write cache destination.
  4. Click OK to exit the vDisk Properties dialog.

 

Provisioning Services or Machine Creation Services (2016 Edition)

When you want to migrate from Citrix 6.5 to Citrix 7.x, you need to make some decisions and one of the most important one is to choose whether to go for PVS or MCS. I have done some searches and found a lot of articles but some of them are really good and based on the real experiences. Have a look at this : (when you are making decisions)

PVSvMCS

And this;

compare

From Barry Schiffer web site, he explains and puts things in a different perspective for anyone making this decision;

Let’s start with the first decision in the tree in which we ask the question about using a XenDesktop only, XenApp only or mixed platform. The reason for this is that, before XenDesktop 7, it wasn’t possible to do MCS for XenApp load. Since XenDesktop 7 it’s actually possible to use Machine Creation Services for XenApp.

IOPS

In the old days we were worried about boot and logoff storms because of the amount of IOPS this generated on our expensive shared storage systems. If so we would advice to use Provisioning Services because of better IOPS caching possibilities.

Lots has changed in the past few years but the IOPS load is pretty much still the same, yet the decision making process changed. The reason for this change is that we now have more knowledge about the amount of IOPS and vendors jumped in and created new solutions offering huge amounts of IOPS on central or local storage.
On the hypervisor level we are now able to do live storage migrations. This helps us when we need to perform management tasks and don’t have the time to wait for all of the users to close their sessions.

Thin Provisioning

For Machine Creation Services it’s highly recommended to use a storage solution that offers the ability to utilize thin provisioning. This way we only use as much data as we need for write caching. If we don’t utilize thin provisioning each target will use as much disk space as the configured base image.

Persistency

Another decision is the need for dedicated aka persistent virtual desktops. If we need persistency you were forced to use Machine Creation Services. The reason for this decision was based on the fact that Provisioning Services falls back to Server Side caching when the cache had to be persistent. This method of caching results in a crappy desktop performance.
Since the introduction of Citrix Provisioning Services 6 we are able to offer persistent caching on the local target hard disk, which pretty much solves this issue. We therefore are now able to utilize Provisioning Services and Machine Creation Services for persistent desktops.

Physical vs Virtual

When we have a demand for physical virtual desktops we still need Provisioning Services. Machine Creation Services integrates on the hypervisor storage layer and therefore can’t be used on a physical target. This is the simplest decision of them all!

Advanced Image Management

As a reader of my blog you should already know that I like automation therefore I would never update images but instead rollout a new image. This way I can retest my image deployment every once in a while . Not of lesser importance I can always go back to my deployment run books to see how a certain component was installed for troubleshooting purposes.

If you care about image versioning and do a lot of image updates Provisioning Services is your way to go. Provisioning Services gives you greater flexibility to work with image versions and updates. Not everyone agrees with me on this one so I have decided to keep this out of the decision tree for now.

Multiple image locations or multiple images

This section has been added after publishing the article because the decisions attracts some attention, mostly by the guys from Atlantis Computing which must mean this market space has their full attention:). When we look at the Provisioning Services (PVS) architecture we have a central image store, the PVS server, for the sake of keeping things simple I’m not going into where PVS gets the image from local, filer, DFS et cetera. Machine Creation Services (MCS) works on the storage layer and places the image on each datastore which is used for targets.
When I create a new image or update an image with PVS I just change the pointer for each target and I’m done. With MCS that’s different, MCS first creates a single imagefile from a VM snapshot and when finished copies that image to each datastore. This process takes up CPU, IO and network resources and can take up to an hour in one of my production platforms (SSD 10Gbit et cetera).
So imagine a VDI cluster with 12 hosts with locally presented storage, this could be SSD, FusionIO or just as easily Atlantis ILIO. This would mean we have, at least, 12 storage datastores. With PVS this all stays simple, PVS is the central image location. With MCS this would mean we copy the base image to 12 different datastores.
Aside from the multiple image locations think about what happens if you have more then one image. This is not uncommon in enterprises, an example could be a VDI image, an RDS image with Internet Explorer 10 and one with Internet Explorer 11. This would mean that for MCS we copy not one image to 12 datastores but three images to 12 datastores. Think about the time and resources going into maintaining those images.
My decision would therefore be to stick with Provisioning Services when you have more then a couple of datastores or images. 

Thanks Barry Schiffer, this is an awesome article.

 

Provisioning Services – Cache Options

How to access these options?

These cache options I have previously mentioned can be accessed via the properties of the vDisk. (To create one go to Store, right click and choose create a new vDisk)

PVS1

Under access mode, if it is showing Private Image, cache type will be grayed out which is saying vDisk is currently in used and you can’t change this option. When you change the Access mode to Standard Image then you have options available;

PVS2