I have an script with the cmdlet trimstart and I've checked that when the string that I want starts with "S" it trims the "S" too. F.ex. i have
$user='POSPOCPA\Super3'
$user=$user.TrimStart("POSPOCPA\")
The result is $user=uper3
but if I have
$user='POSPOCPA\super3'
$user=$user.trimstart("POSPOCPA\")
then the result is ok $user=Super3
is there any explication for this?
Thanks
A problem with trimstart cmdlet
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: A problem with trimstart cmdlet
This is a little used feature of Windows PowerShell.
This is the current way to enable the feature.
PS C:\scripts> $user='POSPOCPA\Super3'
PS C:\scripts> $user.TrimStart("POsPOCPA\")
SPOCPA\Super3
This is the current way to enable the feature.
PS C:\scripts> $user='POSPOCPA\Super3'
PS C:\scripts> $user.TrimStart("POsPOCPA\")
SPOCPA\Super3
Re: A problem with trimstart cmdlet
If you read the documentation for the "TrimStart" method he answer will become very clear. The issue si the "TrimStart" does not do what you think it does:
https://msdn.microsoft.com/en-us/librar ... .110).aspx
https://msdn.microsoft.com/en-us/librar ... .110).aspx
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am