Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Remove i:0#.w|ad\ Prefix using PowerShell and TrimStart

$
0
0

I am trying to remove 

i:0#.w|ad\

From accounts listed in the groups in SharePoint 2013. Some of our accounts start with ad, which I obviously want to preserve. However I cannot work out how to only trim the first 'ad'. I cannot prevent a second 'ad' from being trimmed, so "i:0#.w|ad\adxxxx" always gives "xxxx".

$testString = "i:0#.w|ad\adxxxx";
$testString.TrimStart($myTrim);

Here is a list of what I have tried (yes, many of these are not even close and just symptomatic of my increasing desperation). The 'i:0#.w|' seems to trim just fine on it's own without any escaping, but of course leaves '\ad' which I want to remove.

$myTrim = 'i:0#.w\|"ad\"?'
$myTrim = 'i:0#.w|"ad\"?'
$myTrim = 'i:0#.w|"ad\"{1}'
$myTrim = "(i:0#.w\|ad\)"
$myTrim = "(i:0#.w|ad\)"
$myTrim = "(i:0#\.w\|ad\)"
$myTrim = "(i:0#\.w\|ad\\)"
$myTrim = "[i:0#.w\|ad\\]"
$myTrim = "[i:0#.w|ad\]"
$myTrim = "<i:0#\.w\|*?\\ad>"
$myTrim = "<i:0#\.w\|>?<\\ad>"
$myTrim = "<i:0#\.w\|>*?<\\ad>"
$myTrim = "<i:0#\.w\|><\?\ad>"
$myTrim = "<i:0#\.w\|><\\ad>"
$myTrim = "<i:0#\.w\|><\\ad>(0)"
$myTrim = "<i:0#\.w\|><\\ad>(1)"
$myTrim = "<i:0#\.w\|><\\ad>{1}"
$myTrim = "<i:0#\.w\|ad\\>"
$myTrim = "i:0#.w\|","ad\?"
$myTrim = "i:0#.w\|ad\?"
$myTrim = "i:0#.w|?ad\"
$myTrim = "i:0#.w|""ad?\"
$myTrim = "i:0#.w|(ad\)?"
$myTrim = "i:0#.w|(ad\){1}"
$myTrim = "i:0#.w|a?d?\?"
$myTrim = "i:0#.w|ad?\"
$myTrim = "i:0#.w|ad"
$myTrim = "i:0#.w|ad\?"
$myTrim = "i:0#.w|ad\"
$myTrim = "i:0#\.w\|*?\\ad"
$myTrim = "i:0#\.w\|ad\?"
$myTrim = "i\:\0\#\.w\|ad\?"
$myTrim = "i\:0\#\.w\|*?\\ad"
$myTrim = "i\:0\#\.w\|ad\?"

Viewing all articles
Browse latest Browse all 21975

Trending Articles