Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Replace character with backslash

Posted on 2013-11-04
3
298 Views
Last Modified: 2013-11-04
I have run in to at bit of a problem.
I have some Groupnames in the format AAA.BBB.CCC and I want to replace all the dots with backslashes.

I have tried with this:
$a = "AAA.BBB.CCC"
$a -replace ".","\"

Open in new window

But it just returns:
\\\\\\\\\\\\

Open in new window

How do I force it to return
AAA\BBB\CCC

Open in new window

0
Comment
Question by:Kasper Katzmann
3 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 39621227
Hi,
the period means any character hence you have to "escape" it like
$a = "AAA.BBB.CCC"
$a -replace "\.","\"

Open in new window


HTH
Rainer
0
 

Author Closing Comment

by:Kasper Katzmann
ID: 39621233
Thanks a lot. I was convinced it was the "\" that caused the problem.
0
 
LVL 14

Expert Comment

by:Ram Balachandran
ID: 39621247
$a.Split(".") | ForEach {  Write-Host "$_/" -nonewline}
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This article will help you understand what HashTables are and how to use them in PowerShell.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question