Private/New-GPCExtension.ps1
|
function New-GPCExtension { ################################################################################ ##### ##### ##### Define the new gPCMachineExtensionNames value ##### ##### [{CSE GUID 1}{Tool Extension GUID 1}] ##### ##### ##### ################################################################################ Param([string] $OldValue, [string] $CSEGUID, [string] $TOOLGUID) $Info = Measure-FunctionRuntime -Begin #Write-Host "CSE GUID = $CSEGUID" #Write-host "TOOL GUID = $TOOLGUID" #Write-Host "Old Value = $OldValue" -ForegroundColor green #add the default prefix if missing If (-not $OldValue.Contains($Script:StartGUID)) { $OldValue = "[{00000000-0000-0000-0000-000000000000}]" + $OldValue } $result = $OldValue.split("[") #skip for User Rights Assignment, not needed If ($TOOLGUID -ne $Script:ToolGUIDComputerPolicySettings) { #define new prefix $prefix = "[" + $result[1] $prefix = $prefix.Replace("[", "").Replace("]", "") $prefix = $prefix + $TOOLGUID $tempresult = $prefix.Split("{") | Sort-Object $newPreFix = $tempresult -join "{" $newPreFix = "[" + $newPreFix + "]" } else { $newPreFix = "[" + $result[1] } #define new postfix $postfix = "" for ($i = 2; $i -lt $result.Count; $i++) { $postfix = $postfix + "[" + $result[$i] } $TempValue = $postfix + "[" + $CSEGUID + $TOOLGUID + "]" $result = $TempValue.Split("[") | Sort-Object $newPostFix = $result -join "[" $newValue = $newPreFix + $newPostFix #Write-Host "New Value = $newValue" -ForegroundColor Cyan Write-Log -Message " >> Cse GUID = $CSEGUID" Write-Log -Message " >> Tool GUID = $TOOLGUID" Write-Log -Message " >> Old Value = $OldValue" Write-Log -Message " >> New Value = $newValue" Measure-FunctionRuntime -End -Details $Info return $newValue } |