Solved

Replace character with backslash

Posted on 2013-11-04
3
295 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
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 Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

910 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now