In PowerShell, you can discover the methods available to an object with Get-Member, these methods are mostly used to manipulate powershell variables.
For an integer: 123 | get-member
Will return the methods: CompareTo, Equals, GetHashCode, GetType, GetTypeCode, ToString
So you can do:
(123).equals(456) which will return false
($myVar1).CompareTo($MyVar2)
($myVar).ToString()
Note that CompareTo() differs from equals() in that it returns different values if the item is greater than or less than.
For a string: "The world is everlasting" | get-member
Will return the methods: Clone, CompareTo, Contains, CopyTo, EndsWith, Equals,GetEnumerator,
GetHashCode, GetType, GetTypeCode, GetChars, GetLength, IndexOf, IndexOfAny, Insert,
IsNormalised, LastIndexOf,
LastIndexOfAny, Normalize, PadLeft, PadRight, Remove,
Replace,Split, StartsWith, Substring, ToCharArray, ToLower, ToLowerInvariant, ToString,
ToUpper,ToUpperInvariant, Trim,TrimEnd,TrimStart, Chars, Length
So you can do:
($myStringVar1).ToLower()
($myStringVar1).equals(myStringVar2)
($myStringVar1).CompareTo(myStringVar2)
($myStringVar1).PadRight() + "**"
("a b c").split("b")
Some typical Methods:
Clone()
Create()
Delete()
Chars(IntIndex) {get;}
CompareTo(Object )
CompareTo(String)
Contains(strValue)
CopyTo(IntSourceIndex, strDestination, IntDestinationIndex, IntCount)
EndsWith(String [, StringComparisonType])
Equals(Object)
Equals(strValue)
Equals(strValue, StringComparisonType)
get_CreationTime()
get_CreationTimeUtc()
GetEnumerator()
get_FullName()
get_LastAccessTime()
get_LastWriteTime()
GetType()
get_Chars(IntIndex)
get_Length()
IndexOf(StrValue, IntStartIndex, IntCount)
IndexOfAny(strAnyOf, [IntStartIndex, IntCount])
Insert(IntStartIndex, String value)
Length {get;}
PadLeft(IntTotalWidth [, StrPaddingChar] )
PadRight(IntTotalWidth [, StrPaddingChar] )
Remove(IntStartIndex [, IntCount])
Replace(strOldChar, strNewChar)
Split(strSeparator [, IntCount])
StartsWith(strValue [,strComparisonType)
Substring(IntStartIndex[, IntLength])
ToCharArray([IntStartIndex, IntLength])
ToLower()
ToString()
ToUpper()
Trim(strTrimChars])
TrimEnd(strTrimChars)
TrimStart(strTrimChars)
“There nearly always is method in madness. It's what drives men mad, being methodical” - G. K. Chesterton
Related:
Get-Item Variable:
Get-Variable