Add new functions for credential handling, node lookup, and context-aware parameter overrides; update module version to 1.2.0

This commit is contained in:
Torsten Brendgen
2026-08-18 22:45:05 +02:00
parent 4b67c74ac0
commit 5a07cded4e
10 changed files with 251 additions and 13 deletions
+100
View File
@@ -424,6 +424,102 @@ ConfigDbName : SharePoint_corp_TST_Farm_Config
`reference(path)` resolves another value from the configuration data by path. `reference(path, property)` resolves the value and then returns a property from it, such as `UserName` from a `PSCredential`.
### Credentials
`credentialWithDomain(credential, domain)` returns a new `PSCredential` with the same password and a domain-qualified user name. If the user name already contains `DOMAIN\User` or `user@domain`, the original credential is returned.
This is useful when a secret backend such as KeePass stores the user name without a domain, but the DSC resource expects a domain-qualified credential:
```powershell
Parameters = @{
DomainNetBIOS = @{
Type = 'string'
Value = 'CONTOSO'
}
FarmCredential = @{
Type = 'credential'
Value = @{
Provider = 'SecretManagement'
Vault = 'KeePass'
Name = 'SharePoint/FarmAccount'
Domain = "[parameters('DomainNetBIOS')]"
}
}
}
```
The same transformation can also be used explicitly in expressions:
```powershell
FarmCredentialQualified = @{
Type = 'credential'
DefaultValue = "[credentialWithDomain(parameters('FarmCredential'), parameters('DomainNetBIOS'))]"
}
```
### Node Lookup
`firstNodeNameWhere(propertyName)` returns the first `NodeName` from `AllNodes` where the named property is `$true`.
`firstNodeNameWhere(propertyName, expectedValue)` compares the property with the provided value.
```powershell
AllNodes = @(
@{
NodeName = 'SP01'
RunCentralAdmin = $true
}
@{
NodeName = 'SP02'
RunCentralAdmin = $false
}
)
```
```powershell
CentralAdministrationHostName = @{
Type = 'string'
DefaultValue = "[firstNodeNameWhere('RunCentralAdmin')]"
}
CentralAdministrationUrl = @{
Type = 'string'
DefaultValue = "[format('https://{0}:{1}', parameters('CentralAdministrationHostName'), parameters('CentralAdministrationPort'))]"
}
```
If a fixed URL is required, set an explicit parameter value and the default expression is not used.
### Parent Map Key
`parentKey()` returns the key of the map that contains the current expression property. It can be used to derive resource-specific parameter names while retaining a shared default:
```powershell
Parameters = @{
DefaultWebApplicationAuthenticationMethod = @{
Type = 'string'
DefaultValue = 'NTLM'
}
HNSCWebApplicationAuthenticationMethod = @{
Type = 'string'
Value = 'Kerberos'
}
}
Resources = @{
WebApplications = @{
HNSC = @{
AuthenticationMethod = "[coalesce(parameters(concat(parentKey(), 'WebApplicationAuthenticationMethod')), parameters('DefaultWebApplicationAuthenticationMethod'))]"
}
MySite = @{
AuthenticationMethod = "[coalesce(parameters(concat(parentKey(), 'WebApplicationAuthenticationMethod')), parameters('DefaultWebApplicationAuthenticationMethod'))]"
}
}
}
```
The `HNSC` resource resolves the optional `HNSCWebApplicationAuthenticationMethod` override. `MySite` falls back to `DefaultWebApplicationAuthenticationMethod` when no corresponding override parameter exists.
### String Composition
```powershell
@@ -628,6 +724,10 @@ ConfigDbName : SharePoint_corp_TST_Farm_Config
- `variables(name)`
- `reference(path)`
- `reference(path, property)`
- `credentialWithDomain(credential, domain)`
- `firstNodeNameWhere(propertyName)`
- `firstNodeNameWhere(propertyName, expectedValue)`
- `parentKey()`
- `concat(value1, value2, ...)`
- `format(formatString, value1, value2, ...)`
- `coalesce(value1, value2, ...)`