{"id":74251,"date":"2015-11-04T00:01:00","date_gmt":"2015-11-04T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2015\/11\/04\/reverse-strings-with-powershell\/"},"modified":"2019-02-18T09:34:40","modified_gmt":"2019-02-18T16:34:40","slug":"reverse-strings-with-powershell","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/reverse-strings-with-powershell\/","title":{"rendered":"Reverse Strings with PowerShell"},"content":{"rendered":"<p><b style=\"font-size:12px\">Summary<\/b><span style=\"font-size:12px\">: Ed Wilson, Microsoft Scripting Guy, talks about using Windows PowerShell to reverse strings.<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\">&nbsp;Hey, Scripting Guy! I am working with Windows PowerShell, and I need to reverse a string. I am surprised there is no reverse method in the string class. It seems like a major oversight. Anyway, can you show me how to do this easily?<\/p>\n<p>&mdash;SS<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\">&nbsp;Hello SS,<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. This week is an awesome week. The MVP Summit is going on, and the Scripting Wife is in Bellevue\/Redmond\/Seattle hanging with thousands of MVPs from around the world. She keeps sending me text messages, like, &#8220;Dude, I just got to see Jaap,&#8221; and &#8220;I was talking to Mark,&#8221; and &#8220;Guess what? Karl is coming to the get-together tonight.&#8221; One was, &#8220;You are not going to believe it. Vlad invited me to sit in on the Jeremy unplugged session! OMG!!!&#8221;<\/p>\n<p>I mean, it is nearly a real-time stream of messages. Then she goes quiet when she is in an NDA session.<\/p>\n<p>Nah, I am not jealous. Nope. Not one bit&#8230;<\/p>\n<p>So, SS. I was sitting on the patio overlooking the pool, and I was sipping a nice cup of English Breakfast tea. I have rather poor WiFi, but I turned on Internet Connection Sharing on my Windows&nbsp;8.1 phone, and boom! My Windows 10 laptop joined the connection and all is good. Actually, the performance is really quite good. I might watch Buffy the Vampire Slayer this evening on Netflix. Yeah, no reason not to. This is working out really well.&nbsp;<span style=\"font-size:12px\">I digress&#8230;<\/span><\/p>\n<p>So you have a string. I&#8217;ll store the string in a variable named <b>$a<\/b>. I then display the contents of the <b>$a<\/b> variable. This is shown here:<\/p>\n<p style=\"margin-left:30px\">PS d:\\&gt; $a = &#8220;abcde&#8221;<\/p>\n<p style=\"margin-left:30px\">PS d:\\&gt; $a<\/p>\n<p style=\"margin-left:30px\">Abcde<\/p>\n<p>I know that I have a System.String, and I can look this up by using the <b>Get-Member<\/b> cmdlet. I pipe the <b>$a<\/b> variable to <b>Get-Member<\/b> (<b>gm<\/b> is an alias) and look through the methods and properties associated with the string object:<\/p>\n<p style=\"margin-left:30px\">PS d:\\&gt; $a | gm<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp; TypeName: System.String<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemberType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Definition<\/p>\n<p style=\"margin-left:30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8212;&#8212;&#8212;-<\/p>\n<p style=\"margin-left:30px\">Clone&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Object Clone(), System.Object ICloneable.Clone()<\/p>\n<p style=\"margin-left:30px\">CompareTo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int CompareTo(System.Object value), int CompareTo(string strB), int IComparab&#8230;<\/p>\n<p style=\"margin-left:30px\">Contains&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool Contains(string value)<\/p>\n<p style=\"margin-left:30px\">CopyTo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int co&#8230;<\/p>\n<p style=\"margin-left:30px\">EndsWith&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool EndsWith(string value), bool EndsWith(string value, System.StringCompari&#8230;<\/p>\n<p style=\"margin-left:30px\">Equals&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool Equals(System.Object obj), bool Equals(string value), bool Equals(string&#8230;<\/p>\n<p style=\"margin-left:30px\">GetEnumerator&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.CharEnumerator GetEnumerator(), System.Collections.IEnumerator IEnumer&#8230;<\/p>\n<p style=\"margin-left:30px\">GetHashCode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int GetHashCode()<\/p>\n<p style=\"margin-left:30px\">GetType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type GetType()<\/p>\n<p style=\"margin-left:30px\">GetTypeCode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.TypeCode GetTypeCode(), System.TypeCode IConvertible.GetTypeCode()<\/p>\n<p style=\"margin-left:30px\">IndexOf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int IndexOf(char value), int IndexOf(char value, int startIndex), int IndexOf&#8230;<\/p>\n<p style=\"margin-left:30px\">IndexOfAny&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int IndexOfAny(char[] anyOf), int IndexOfAny(char[] anyOf, int startIndex), i&#8230;<\/p>\n<p style=\"margin-left:30px\">Insert&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string Insert(int startIndex, string value)<\/p>\n<p style=\"margin-left:30px\">IsNormalized&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool IsNormalized(), bool IsNormalized(System.Text.NormalizationForm normaliz&#8230;<\/p>\n<p style=\"margin-left:30px\">LastIndexOf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int LastIndexOf(char value), int LastIndexOf(char value, int startIndex), int&#8230;<\/p>\n<p style=\"margin-left:30px\">LastIndexOfAny&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int LastIndexOfAny(char[] anyOf), int LastIndexOfAny(char[] anyOf, int startI&#8230;<\/p>\n<p style=\"margin-left:30px\">Normalize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string Normalize(), string Normalize(System.Text.NormalizationForm normalizat&#8230;<\/p>\n<p style=\"margin-left:30px\">PadLeft&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string PadLeft(int totalWidth), string PadLeft(int totalWidth, char paddingChar)<\/p>\n<p style=\"margin-left:30px\">PadRight&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string PadRight(int totalWidth), string PadRight(int totalWidth, char padding&#8230;<\/p>\n<p style=\"margin-left:30px\">Remove&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string Remove(int startIndex, int count), string Remove(int startIndex)<\/p>\n<p style=\"margin-left:30px\">Replace&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string Replace(char oldChar, char newChar), string Replace(string oldValue, s&#8230;<\/p>\n<p style=\"margin-left:30px\">Split&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string[] Split(Params char[] separator), string[] Split(char[] separator, int&#8230;<\/p>\n<p style=\"margin-left:30px\">StartsWith&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bool StartsWith(string value), bool StartsWith(string value, System.StringCom&#8230;<\/p>\n<p style=\"margin-left:30px\">Substring&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string Substring(int startIndex), string Substring(int startIndex, int length)<\/p>\n<p style=\"margin-left:30px\">ToBoolean&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool IConvertible.ToBoolean(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToByte&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; byte IConvertible.ToByte(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToChar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char IConvertible.ToChar(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToCharArray&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char[] ToCharArray(), char[] ToCharArray(int startIndex, int length)<\/p>\n<p style=\"margin-left:30px\">ToDateTime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; datetime IConvertible.ToDateTime(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToDecimal&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; decimal IConvertible.ToDecimal(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToDouble&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double IConvertible.ToDouble(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToInt16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int16 IConvertible.ToInt16(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToInt32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int IConvertible.ToInt32(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToInt64&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; long IConvertible.ToInt64(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToLower&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ToLower(), string ToLower(cultureinfo culture)<\/p>\n<p style=\"margin-left:30px\">ToLowerInvariant Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ToLowerInvariant()<\/p>\n<p style=\"margin-left:30px\">ToSByte&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sbyte IConvertible.ToSByte(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToSingle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float IConvertible.ToSingle(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToString&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ToString(), string ToString(System.IFormatProvider provider), string I&#8230;<\/p>\n<p style=\"margin-left:30px\">ToType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Object IConvertible.ToType(type conversionType, System.IFormatProvider&#8230;<\/p>\n<p style=\"margin-left:30px\">ToUInt16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint16 IConvertible.ToUInt16(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToUInt32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint32 IConvertible.ToUInt32(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToUInt64&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;uint64 IConvertible.ToUInt64(System.IFormatProvider provider)<\/p>\n<p style=\"margin-left:30px\">ToUpper&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ToUpper(), string ToUpper(cultureinfo culture)<\/p>\n<p style=\"margin-left:30px\">ToUpperInvariant Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ToUpperInvariant()<\/p>\n<p style=\"margin-left:30px\">Trim&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string Trim(Params char[] trimChars), string Trim()<\/p>\n<p style=\"margin-left:30px\">TrimEnd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string TrimEnd(Params char[] trimChars)<\/p>\n<p style=\"margin-left:30px\">TrimStart&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string TrimStart(Params char[] trimChars)<\/p>\n<p style=\"margin-left:30px\">Chars&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ParameterizedProperty char Chars(int index) {get;}<\/p>\n<p style=\"margin-left:30px\">Length&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int Length {get;}<\/p>\n<p>I see that there are also some static members that have been added:<\/p>\n<p style=\"margin-left:30px\">PS d:\\&gt; $a | gm -Static<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp; TypeName: System.String<\/p>\n<p style=\"margin-left:30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;MemberType &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Definition<\/p>\n<p style=\"margin-left:30px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8212;&#8212;&#8212;- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8212;&#8212;&#8212;-<\/p>\n<p style=\"margin-left:30px\">Compare&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; static int Compare(string strA, string strB), static int Compare(string strA, string s&#8230;<\/p>\n<p style=\"margin-left:30px\">CompareOrdinal&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; static int CompareOrdinal(string strA, string strB), static int CompareOrdinal(string &#8230;<\/p>\n<p style=\"margin-left:30px\">Concat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; static string Concat(System.Object arg0), static string Concat(System.Object arg0, Sys&#8230;<\/p>\n<p style=\"margin-left:30px\">Copy&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; static string Copy(string str)<\/p>\n<p style=\"margin-left:30px\">Equals&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method &nbsp;&nbsp;&nbsp;&nbsp;static bool Equals(string a, string b), static bool Equals(string a, string b, System&#8230;.<\/p>\n<p style=\"margin-left:30px\">Format&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; static string Format(string format, System.Object arg0), static string Format(string f&#8230;<\/p>\n<p style=\"margin-left:30px\">Intern&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; static string Intern(string str)<\/p>\n<p style=\"margin-left:30px\">IsInterned&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; static string IsInterned(string str)<\/p>\n<p style=\"margin-left:30px\">IsNullOrEmpty&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; static bool IsNullOrEmpty(string value)<\/p>\n<p style=\"margin-left:30px\">IsNullOrWhiteSpace Method&nbsp;&nbsp;&nbsp;&nbsp; static bool IsNullOrWhiteSpace(string value)<\/p>\n<p style=\"margin-left:30px\">Join&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; static string Join(string separator, Params string[] value), static string Join(string&#8230;<\/p>\n<p style=\"margin-left:30px\">new&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; string new(System.Char*, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7&#8230;<\/p>\n<p style=\"margin-left:30px\">ReferenceEquals&nbsp;&nbsp;&nbsp; Method&nbsp;&nbsp;&nbsp;&nbsp; static bool ReferenceEquals(System.Object objA, System.Object objB)<\/p>\n<p style=\"margin-left:30px\">Empty&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Property&nbsp;&nbsp; static string Empty {get;}<\/p>\n<p>The first thing I want to do is to break the string into an array of characters&mdash;a character array. Luckily, there is a string method that does just that. I will store the character array in a new variable, <b>$b<\/b>:<\/p>\n<p style=\"margin-left:30px\">PS d:\\&gt; $b = $a.ToCharArray()<\/p>\n<p style=\"margin-left:30px\">PS d:\\&gt; $b<\/p>\n<p style=\"margin-left:30px\">a<\/p>\n<p style=\"margin-left:30px\">b<\/p>\n<p style=\"margin-left:30px\">c<\/p>\n<p style=\"margin-left:30px\">d<\/p>\n<p style=\"margin-left:30px\">e<\/p>\n<p>So, now I want to reverse the character array. To do this, I use the static reverse method from the <b>[array]<\/b> object:<\/p>\n<p style=\"margin-left:30px\">PS d:\\&gt; [array]::Reverse($b)<\/p>\n<p style=\"margin-left:30px\">PS d:\\&gt; $b<\/p>\n<p style=\"margin-left:30px\">e<\/p>\n<p style=\"margin-left:30px\">d<\/p>\n<p style=\"margin-left:30px\">c<\/p>\n<p style=\"margin-left:30px\">b<\/p>\n<p style=\"margin-left:30px\">a<\/p>\n<p><b>&nbsp; &nbsp;Note&nbsp;<\/b> The cool thing here is that the array reverses order. I do not need to save the output in a new variable. <br><b>&nbsp; &nbsp;$b<\/b> now has a reversed array.<\/p>\n<p>Now I want to regroup the elements of the array back into a string, and store that back into a variable:<\/p>\n<p style=\"margin-left:30px\">PS d:\\&gt; $c = -join($b)<\/p>\n<p style=\"margin-left:30px\">PS d:\\&gt; $c<\/p>\n<p style=\"margin-left:30px\">Edcba<\/p>\n<p>And my string is back to a string again:<\/p>\n<p style=\"margin-left:30px\">PS d:\\&gt; $c.GetType()<\/p>\n<p style=\"margin-left:30px\">IsPublic IsSerial Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BaseType<\/p>\n<p style=\"margin-left:30px\">&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8211;<\/p>\n<p style=\"margin-left:30px\">True&nbsp;&nbsp;&nbsp;&nbsp; True&nbsp;&nbsp;&nbsp;&nbsp; String&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Object<\/p>\n<p>SS, that is all there is to using Windows PowerShell to reverse strings. Join me tomorrow when I will talk about more cools stuff.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy&nbsp;<\/b><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Ed Wilson, Microsoft Scripting Guy, talks about using Windows PowerShell to reverse strings. &nbsp;Hey, Scripting Guy! I am working with Windows PowerShell, and I need to reverse a string. I am surprised there is no reverse method in the string class. It seems like a major oversight. Anyway, can you show me how to [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[3,336,45],"class_list":["post-74251","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-scripting-guy","tag-strings","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Ed Wilson, Microsoft Scripting Guy, talks about using Windows PowerShell to reverse strings. &nbsp;Hey, Scripting Guy! I am working with Windows PowerShell, and I need to reverse a string. I am surprised there is no reverse method in the string class. It seems like a major oversight. Anyway, can you show me how to [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/74251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=74251"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/74251\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=74251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=74251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=74251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}