Replacing digits in a guid
-
Tuesday, January 29, 2013 12:54 PM
Hi,
Is there any way to replace highlighted digits in {26A24AE4-039D-4CA4-87B4-2F86416031FF} in powershell?
Thanks.
All Replies
-
Tuesday, January 29, 2013 2:11 PMModerator
There are ways.
This is one:
$guid = '{26A24AE4-039D-4CA4-87B4-2F86416031FF}' $replace = '99' $regex = '(^.{33})..(.{3})' [regex]::Replace($guid,$regex,{"{1}$Replace{2}" -f $args.groups})
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
- Marked As Answer by PoSHV Tuesday, January 29, 2013 3:02 PM
-
Tuesday, January 29, 2013 2:53 PMModerator
Why? GUIDs are intended to be globally unique (hence the name). If you change digits in a GUID, then it's no longer guaranteed to be unique.
Bill
-
Tuesday, January 29, 2013 3:01 PMThank you. I have got it worked with help of indexof(),insert() and remove().

