troubleshooting Question

PowerShell - Remove Last Comma From Output

Avatar of Bobby Llih
Bobby Llih asked on
Powershell
2 Comments1 Solution169 ViewsLast Modified:
Can someone help, this function will convert strings of text to uppercase and add, "0x##," every two spaces.
However, there is an un-needed comma at the end. How do I remove end comma?
Function Convert_To_Hex ($Hex_01)
{
  $Hex = $Hex_01.ToUpper() -Replace '(..)', '0x$1, '
  Write-Host $Hex
}

Convert_To_Hex 87ceeb

# Output: 0x87, 0xCE, 0xEB,

Thanks In Advanced.
ASKER CERTIFIED SOLUTION
David Johnson, CD
The More I know, the more I don't know
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros