Alternatives for different functionality in DSM 2015.2

Based on the changes introduced in DSM-version 2015.2 in the Policy-handling area, perhaps some of your scripts or applications need to be adopted. Because of object-types, properties, methods or enumeration values no longer being available, it can happen that existing code doesn't work anymore or results in errors. This chapter lists some of the possibly affected actions:


Optionvalue PrepareForReinstall of the option OperationMode from Computer-objects:


The commands


$MyComputer.OperationMode = "PrepareForReinstall"

$MyComputer.Update()


and also calling the appropriate method


$MyComputer.PrepareForReinstall()

       

do not work any longer and result in throwing an error message.


The reason is, that the value PrepareForReinstall is no longer valid for the property OperationMode (Computer.OperationMode)


As a workaround, in some situations the following commands can be used:


$MyComputer.OperationMode = "Inactive"

$MyComputer.Update()


or alternatively


$MyComputer.Deactivate()


During a computer-reinstallation


$MyComputer | Reinstall-EmdbComputer <options> -- without -StartImmediate


the Reinstall-EmdbComputer cmdlet can be uses without the switch -StartImmediately. After finishing the action, the value of the OperationMode property of the Computer is Inactive.


Note: For DSM versions prior DSM 2015.2 when executing the Reinstall-EmdbComputer cmdlet, the value of the OperationMode property ist set to PrepareForReinstall.



Properties ServerRolloutState and ExecutionMode of Policy-Instances:


The commands


$MyPolicyInstance.ServerRolloutState = "<Wert>"

$MyPolicyInstance.ExecutionMode = "<Wert>"

$MyPolicyInstance.Update()

       

do no longer work and result in an error message.


The reason for this new behaviour is, that the properties ServerRolloutState and ExecutionMode of Policy-Instances are now write-protected.


1. Reinstallation of Policy-Instances


That means, instead of the code that was used in prior versions of DSM, like the one below


$MyPolicyInstance.ServerRolloutState = "ToBeRedelivered"

$MyPolicyInstance.ExecutionMode = "Reinstall"

$MyPolicyInstance.Update()


either the Reinstall()-method


$MyPolicyInstance.Reinstall()


or the following code


$MyPolicyInstance.ReinstallRequestNumber++

$MyPolicyInstance.Update()


has to be used


Note: For DSM versions prior DSM 2015.2 when calling the Reinstall()-method, the properties ServerRolloutState and ExecutionMode are used.


2. Repair of Policy-Instances


That means, in order to execute Policy-Instances again in Repair-mode, instead of using the following code


$MyPolicyInstance.ServerRolloutState = "ToBeRedelivered"

$MyPolicyInstance.ExecutionMode = "Repair"

$MyPolicyInstance.Update()


either the Repair()-method


$MyPolicyInstance.Repair()


or the following commands


$MyPolicyInstance.RepairRequestNumber++

$MyPolicyInstance.Update()


must be used.


Note: For DSM versions prior DSM 2015.2 when calling the Repair()-method, the properties ServerRolloutState and ExecutionMode are used.



Functional extensions TargetID:Resolve... for LDAP filter at SOAP API GetPolicyList (EmdbHelpers.GetEmdbPolicyList)


The functional extensions TargetID:Resolve... are no longer available. Their use results in an error message.


Remedy:

1. Extension TargetID:ResolveDirect


$MyTarget = Get-EmdbComputer ...

$MyTarget.GetPolicies()

$MyTarget.GetPolicies($null, "ThisItemIsTarget") # $null = means all Policy-Types


2. Extension TargetID:ResolveGroups


$MyTarget = Get-EmdbComputer ...

$MyTarget.GetPolicies($null, "ThisItemHierarchyIsTarget") # $null = means all Policy-Types


Note: This command retrieves, as apposed to TargetID:ResolveGroups, also Policies for Dynamic Groups.


3. Extension TargetID:ResolveHierarchical


$MyTarget = Get-EmdbComputer ...

$MyTarget.GetPolicies($null, "ThisItemGroupsIsTarget") # $null = means all Policy-Types


4. Extension TargetID:ResolveDirectIn


a) option also available in older DSM versions (EmdbHelpers: GetEmdbPolicyList, GetEmdbPolicies):


$targets = Get-EmdbComputer ...

$drive = $targets[0].Drive

$ids = $targets | % { $_.ID }

$in = [string]::Join(",", $ids)

$ldap = New-Object NwcServices.EnteoV6Tools.Blsadministration.BlsLdapUrl $null, "subtree", $null, "TargetId:ResolveDirectIn=$($in)" # <path>, <scope>, <attributes>, <filter>

$ids = [NwcServices.EnteoV6Tools.Blsadministration.EmdbHelpers]::GetEmdbPolicyList($drive, $ldap) | % { $_.ID }

$policies = [NwcServices.EnteoV6Tools.Blsadministration.EmdbHelpers]::GetEmdbPolicies($drive, $ids)


b) based on assignment targets (method GetPolicies on the assignment target)


$targets = Get-EmdbComputer ...

# .GetPolicies() = all Policy-Types, or e.g. .GetPolicies("SwPolicy") = Software-Policies only...

$policies = $targets | % { $_.GetPolicies() } | sort -Property ID -Unique


c) based on Policy-Types (method GetPolicies on the BlsEmdb drive)


$targets = Get-EmdbComputer ...

$drive = $targets[0].Drive

$lookup = @{}; $targets | % { $lookup[$_.ID] = $_ }

# .GetPolicies() = all, or e.g. .GetPolicies("SwPolicy") = Software-Policies only...

$policies = $drive.GetPolicies() | where { @($_.TargetObjectList | where { $lookup.ContainsKey($_.TargetObjectID) }).Count -gt 0 }


d) based on Policy-Types (EmdbHelpers: GetEmdbPolicyList, GetEmdbPolicies)


$targets = Get-EmdbComputer ...

$drive = $targets[0].Drive

$ids = $targets | % { $_.ID }

$in = [string]::Join(",", $ids)

$ldap = New-Object NwcServices.EnteoV6Tools.Blsadministration.BlsLdapUrl $null, "subtree", $null, "SchemaTag=SwPolicy" # <path>, <scope>, <attributes>, <filter>

$ids = [NwcServices.EnteoV6Tools.Blsadministration.EmdbHelpers]::GetEmdbPolicyList($drive, $ldap) | % { $_.ID }

$ldap = New-Object NwcServices.EnteoV6Tools.Blsadministration.BlsLdapUrl $null, "subtree", $null, "SchemaTag=PnpPolicy" # <path>, <scope>, <attributes>, <filter>

$ids += [NwcServices.EnteoV6Tools.Blsadministration.EmdbHelpers]::GetEmdbPolicyList($drive, $ldap) | % { $_.ID }

$policies = [NwcServices.EnteoV6Tools.Blsadministration.EmdbHelpers]::GetEmdbPolicies($drive, $ids)


Note: One SOAP request per Policy(-Schema)-type seems necessary. An LDAP filter like

$ldap = New-Object NwcServices.EnteoV6Tools.Blsadministration.BlsLdapUrl $null, "subtree", $null, "(|(SchemaTag=SwPolicy)(SchemaTag=PnpPolicy))"

is plausible and syntactically correct - but is not accepted by the BLS. An LDAP filter like

$ldap = New-Object NwcServices.EnteoV6Tools.Blsadministration.BlsLdapUrl $null, "subtree", $null, "(|(PolicySchemaTag=SwPolicy)(PolicySchemaTag=PnpPolicy))"

ist accepted by the BLS and returns the correct results, but is not described in the API documentation.


Note: Independent how $targets is retrieved, the options described above need...

a)   : two SOAP calls (GetEmdbPolicyList, GetEmdbPolicies)

b)   : one SOAP call per assignment-target (<target>.GetPolicies(...))

c)   : two SOAP call per Policy-Type (<drive>.GetPolicies(...)) [* if a Policy-Type is not present, the second SOAP call is omitted]

d)   : one SOAP call per Policy-Type (GetEmdbPolicyList) plus one SOAP call (GetEmdbPolicies) [* closest to a)]


Note: a) and d) are returning MdsPolicy objects, b) and c) are returning EmdbPolicy objects

(conversion MdsPolicy to EmdbPolicy e.g..: $emdbPolicies = [NwcServices.EnteoV6Tools.Blsadministration.EmdbItem]::AsEmdbItem($mdsPolicies, $drive) )