Powershell add registry item

HI All I am trying to add registry with following syntax using Powershell , cant seem to get it working , is it the curly brackets ??? I can run it on the machine fine so I know syntax is correct, just the way Bigfix handles the { and } has me stumped since its there twice as part of the registry key.

HKLM:SYSTEM\KES{{9b03c1d9-3138-44ed-9fae-d9f4c034b88d}}{{16e0423f-7058-48c9-a204-725362b67639}}\Default"

action uses wow64 redirection {not x64 of operating system}

delete __createfile
createfile until END_OF_FILE

// Force registry settings to be machine wide x64 - Add to Trusted Site

// New-ItemProperty ā€œHKLM:SYSTEM\KES{{9b03c1d9-3138-44ed-9fae-d9f4c034b88d}}{{16e0423f-7058-48c9-a204-725362b67639}}\Defaultā€ -Name ā€œGroupingTagsā€ -Value ā€œAlphaā€ -PropertyType ā€œStringā€

END_OF_FILE

delete powershell.ps1
move __createfile powershell.ps1

waithidden { pathname of file ((it as string) of value ā€œPathā€ of key ā€œHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShellā€ of native registry) } -ExecutionPolicy Bypass -File powershell.ps1
//**Begin Closing Marker
// Get the return code of the previous action.
parameter ā€œreturnCodeā€ = ā€œ{exit code of action}ā€

// Task will now exit.
exit {parameter ā€œreturnCodeā€}
//**End Closing Marker

You need to escape each opening curly bracket that is not surrounding relevance with an additional curly bracket. Your key name has a lot of opening curly brackets - you just double up each of them.

Without using Powershell:

action uses wow64 redirection {not x64 of operating system}

if {x64 of operating system}
	regset64 "[HKEY_LOCAL_MACHINE\SYSTEM\KES{{{{9b03c1d9-3138-44ed-9fae-d9f4c034b88d}}{{{{16e0423f-7058-48c9-a204-725362b67639}}\Default]" "GroupingTags"="Alpha"
else
	regset "[HKEY_LOCAL_MACHINE\SYSTEM\KES{{{{9b03c1d9-3138-44ed-9fae-d9f4c034b88d}}{{{{16e0423f-7058-48c9-a204-725362b67639}}\Default]" "GroupingTags"="Alpha"
endif
2 Likes

trn - many thanks using QNA tool I can see its fine :slight_smile:however it does not add the registry value

To clarify the actual registry key is as following - notes {} brackets are single
: HKLM:SYSTEM\KES{9b03c1d9-3138-44ed-9fae-d9f4c034b88d}{16e0423f-7058-48c9-a204-725362b67639}\Default"

Originally I tried double
HKLM:SYSTEM\KES{{9b03c1d9-3138-44ed-9fae-d9f4c034b88d}}{{16e0423f-7058-48c9-a204-725362b67639}}\Default"

Also followed your syntax - and still no success

QND results below :
STATUS: Running actionā€¦
Wow64 redirection disabled. action uses wow64 redirection {not x64 of operating system}
Command succeeded delete No ā€˜C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData__FixletDebugger__createfileā€™ exists to delete, no failure reported
Command succeeded createfile until
Command succeeded delete powershell.ps1
Command succeeded move __createfile powershell.ps1
Command started - waithidden C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File powershell.ps1
Command succeeded (Exit Code=0) waithidden C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File powershell.ps1
Command succeeded parameter ā€œreturnCodeā€ = "7"
Command succeeded (7) exit {parameter ā€œreturnCodeā€}

ā€” Result ā€”
Evaluation completed successfully!

Iā€™m still not quite sure why you are persisting in using Powershell when there are native actionscript commands to achieve what you want.

Also, unless formatted as code, the forum can get confused by a backslash so, to clarify, is the key you want

HKEY_LOCAL_MACHINE\SYSTEM\KES{9b03c1d9-3138-44ed-9fae-d9f4c034b88d}{16e0423f-7058-48c9-a204-725362b67639}\Default

or

HKEY_LOCAL_MACHINE\SYSTEM\KES\{9b03c1d9-3138-44ed-9fae-d9f4c034b88d}{16e0423f-7058-48c9-a204-725362b67639}\Default

As for relevance substitutions, see this post by @JasonWalker

To help further we need your actionscript formatted as code - the </> button

2 Likes