Dealing with versioning in XenDesktop PowerShell SDKs

2:33 PM
Dealing with versioning in XenDesktop PowerShell SDKs -

versioning strategy PowerShell SDK

XenDesktop aims to maintain its SDKs PowerShell backward compatible, meaning administrators (via the control interface or scripts) must not be aware of the version of the controller services are in communication with, or the version of the client / snap-ins modules are installed.

However, from time to time there are changes that are significant enough to make this impossible. The goal is always to keep the largest number of applets backward compatible as possible to scripts continue to function, but it might be a new client-side PowerShell Module / snap-in is required for new versions of service. Such is the case for the XD 7 Press when the new PowerShell snap-ins are provided that will not work with the services XD 5.x and you can not use XD5.x snap-ins to communicate with service XD7.

The other aspect to versioning is that the new versions of XenDesktop are released, a new feature is added and scripts / admins should be able to use these when possible.

Writing scripts to manage different versions

There are various techniques you might want to deploy depending on what you are trying to achieve, and if the scripts have need to change dynamically or if they are simply detect the version at the front then the appropriate set of cmdlets. The following section defines some techniques that can be used.

customer loading SDK

All SDK modules / snapins have unique names Citrix format. .Admin .V . This allows multiple versions of the same SDK to be installed and even loaded at the same time if necessary.

The required version of a snapin can be determined by examining the SDK service version reported by the Central Configuration Service records for the site (ie Get-ConfigRegisteredServiceInstance -InstanceType SDK).

the correct module / snap-in can then be loaded or if all modules / snap-ins for the service are charged the right can be used by name-spacing (to avoid conflicts), for example Citrix .ADIdenity.Admin.V2 Get-AcctIdentyPool would use the V2 snap in

Note :. The snapin Central Configuration Service is special in that V2 snap has limited ability to communicate with both the V1 and V2 Central configuration services; The main feature that is available for V2 snap-in to talk to a V1 service is the cmdlet Get-RegisteredServiceInstance.

The availability of features

The features can be found in the services of the controller but not available from the client when the client is a version older than the services, in addition, they may not be available even though applets for them are present on the client if the service on the controller is older than the client version. So it is not really a good idea to think that just because there is a cmdlet with the setting you want to use available it will work as expected.

The way SDKs provide XenDestkop to handle this is through a capacity mechanism. Each PowerShell Module / snap-in has a cmdlet called Get- ServiceAddedCapability. This cmdlet returns a list of supported features for the combination of services and the client is used.

This allows choices to make based on the capabilities that are defined as available.

sample script

The following is a sample script that illustrates these techniques. It is not intended to set a final model to solve these problems, but rather to provide examples of how they could be used if desired.

 #load appropriate service Central Configuration $ CCS_snapin_toUse = "" $ snap-in CCS_loaded_snapins = @ (Get-PsSnapin Citrix.Configuration.Admin. *) If ($ CCS_loaded_snapins.Count -eq 0) {#no CCS CCS snapins responsible manner support a $ CCS_Available_snapins = @ (Get-PsSnapin Citrix.Configuration.Admin. -reg *) add-PSSnapin -name $ CCS_Available_snapins [0] .name} if ($ CCS_loaded_snapins.Count eq 1) {#a CCS snapin is loaded using the $ CCS_snapin_toUse = $ CCS_Available_snapins [0]} if ($ CCS_loaded_snapins. -gt Count 1) {#more a snapin CCS is responsible for using the latest first CCS_snapin_toUse = $ CCS_Available_snapins [($CCS_Available_snapins.Count-1)] $ #need} namespace to this call incase there is more than one charge here $ CLServiceSDKExpression = "$ (($ CCS_snapin_toUse) .name)  Get-ConfigRegisteredServiceInstance -InterfaceType SDK -ServiceType Log" = $ CLServiceSDK Invoke- expression $ CLServiceSDKExpression $ BrokerServiceSDKExpression = "$ (($ CCS_snapin_toUse) .name)  Get-ConfigRegisteredServiceInstance -InterfaceType SDK -ServiceType Broker" $ BrokerServiceSDK = Invoke-expression $ # BrokerServiceSDKExpression could continue with all Citrix snap-ins loaded, then the name of space each cmdlet call # ------------------ ----------------- ----- or simply # ensure that the necessary versions are responsible for the environment that you speak to this script # removes all snap-ins, and then re-added versions required to avoid name space issues # another alternative at this stage is forking separate process based on the sensed version # was exclusively for this release #make sure there is not already loaded snap-ins for necessary services Remove-PsSnapin Citrix. ConfigurationLogging.Admin. * Remove-PsSnapin Citrix.Broker.Admin. * #load Recording Configuration snap (and use it if you are ... this is new to XD7 therefore may not exist) $ ConfigLoggingSnapinName = "Citrix.ConfigurationLogging .Admin.V" + $ CLServiceSDK .version $ CLSnapin = Get-PsSnapin $ ConfigLoggingSnapinName -registered -ErrorAction Continue if ($ CLSnapin -do "") {Add-PsSnapin -Name $ ConfigLoggingSnapinName $ highLevelLog = Start-LogHighLevelOperation -Source "TestScript" -Text "Demo operation"} #load the correct version of the snap-in broker and if it supports the use of the feature configuration record $ BrokerSnapinName = "Citrix.Broker.admin.V" + $ BrokerServiceSDK.Version $ BrokerSnapin = Get-PsSnapin $ BrokerSnapinName -registered -ErrorAction Continue if ($ BrokerSnapin -do "") {Add-PsSnapin catalogs BrokerSnapinName $ $ = Get-BrokerCatalog # verify that the version available broker supports recording and # configuration to meet the need if (($ highLevelLog -do "") -and ((Get-BrokerServiceAddedCapability) -contains "ConfigurationLogging")) {$ catalogs | Set-BrokerCatalogMetadata -Name "test" -Value "updated by the script" -LoggingId $ highLevlLogID.ID} else {$ catalogs | Set-BrokerCatalogMetadata -Name "test" -Value "updated by the script"}} if ($ highLevlLog -do "") {Stop LogHighLevelOperation -HighLevelOperationId $ highLevelLog.ID -IsSuccessful $ True} 
Previous
Next Post »
0 Komentar