Link to home
Start Free TrialLog in
Avatar of fireburn11
fireburn11

asked on

powershell script to replace string in displayname

Hi Experts,

I need a Quest  powershell script that replace few charactors in displayname.

For example, My displayname is "fireburn company ABC", I want it to change it to be changed to "fireburn company DEF".

Please advise.

Thanks
SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
FYI -Replace will replace anything matches the input value from a string, for example.. If you have a display name  <Test abcedf ABC> the the result will be <Test DEFedf DEF>. But for sure if you think there is no such matching display name you can use -replace..
No Subsun, that is why there is a "$" in the matching string.  To ensure it matches ABC only at the end of the string.


PS C:\Users\Carlo> "ABC  ABC  ABC" -replace 'ABC$','DEF'
ABC  ABC  DEF
PS C:\Users\Carlo>

Open in new window

@Carlo-Giuliani, Sorry I didn’t notice the $.. You are right..