Advertisement
Guest User

Untitled

a guest
Apr 15th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.29 KB | None | 0 0
  1. # Calculated property
  2. PS C:\Windows\system32> "bits" | Get-Service
  3.  
  4. Status Name DisplayName
  5. ------ ---- -----------
  6. Running bits Background Intelligent Transfer Ser...
  7.  
  8.  
  9. PS C:\Windows\system32> "bits" | Select @{N='foo';E={$_.ToString()}} | Get-Service
  10. Get-Service : Cannot find any service with service name '@{foo=bits}'.
  11. At line:1 char:48
  12. + "bits" | Select @{N='foo';E={$_.ToString()}} | Get-Service
  13. + ~~~~~~~~~~~
  14. + CategoryInfo : ObjectNotFound: (@{foo=bits}:String) [Get-Service], ServiceCommandException
  15. + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand
  16.  
  17. PS C:\Windows\system32> "bits" | Select @{N='foo';E={$_.ToString()}} | gm
  18.  
  19.  
  20. TypeName: Selected.System.String
  21.  
  22. Name MemberType Definition
  23. ---- ---------- ----------
  24. Equals Method bool Equals(System.Object obj)
  25. GetHashCode Method int GetHashCode()
  26. GetType Method type GetType()
  27. ToString Method string ToString()
  28. foo NoteProperty System.String foo=bits
  29.  
  30.  
  31. PS C:\Windows\system32> "foo" | gm
  32.  
  33. # now let's try a custom object
  34.  
  35. PS C:\Windows\system32> $a = new-object psobject -property @{
  36. >> [string]"foo" = "bits"
  37. >> }
  38. >>
  39. PS C:\Windows\system32> $a
  40.  
  41. foo
  42. ---
  43. bits
  44.  
  45.  
  46. PS C:\Windows\system32> $a | gm
  47.  
  48.  
  49. TypeName: System.Management.Automation.PSCustomObject
  50.  
  51. Name MemberType Definition
  52. ---- ---------- ----------
  53. Equals Method bool Equals(System.Object obj)
  54. GetHashCode Method int GetHashCode()
  55. GetType Method type GetType()
  56. ToString Method string ToString()
  57. foo NoteProperty System.String foo=bits
  58.  
  59.  
  60. PS C:\Windows\system32> $a.foo | gm
  61.  
  62.  
  63. TypeName: System.String
  64.  
  65. Name MemberType Definition
  66. ---- ---------- ----------
  67. Clone Method System.Object Clone(), System.Object ICloneable.Clone()
  68. CompareTo Method int CompareTo(System.Object value), int CompareTo(string strB), int IComparab...
  69. Contains Method bool Contains(string value)
  70. CopyTo Method void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int co...
  71. EndsWith Method bool EndsWith(string value), bool EndsWith(string value, System.StringCompari...
  72. Equals Method bool Equals(System.Object obj), bool Equals(string value), bool Equals(string...
  73. GetEnumerator Method System.CharEnumerator GetEnumerator(), System.Collections.Generic.IEnumerator...
  74. GetHashCode Method int GetHashCode()
  75. GetType Method type GetType()
  76. GetTypeCode Method System.TypeCode GetTypeCode(), System.TypeCode IConvertible.GetTypeCode()
  77. IndexOf Method int IndexOf(char value), int IndexOf(char value, int startIndex), int IndexOf...
  78. IndexOfAny Method int IndexOfAny(char[] anyOf), int IndexOfAny(char[] anyOf, int startIndex), i...
  79. Insert Method string Insert(int startIndex, string value)
  80. IsNormalized Method bool IsNormalized(), bool IsNormalized(System.Text.NormalizationForm normaliz...
  81. LastIndexOf Method int LastIndexOf(char value), int LastIndexOf(char value, int startIndex), int...
  82. LastIndexOfAny Method int LastIndexOfAny(char[] anyOf), int LastIndexOfAny(char[] anyOf, int startI...
  83. Normalize Method string Normalize(), string Normalize(System.Text.NormalizationForm normalizat...
  84. PadLeft Method string PadLeft(int totalWidth), string PadLeft(int totalWidth, char paddingChar)
  85. PadRight Method string PadRight(int totalWidth), string PadRight(int totalWidth, char padding...
  86. Remove Method string Remove(int startIndex, int count), string Remove(int startIndex)
  87. Replace Method string Replace(char oldChar, char newChar), string Replace(string oldValue, s...
  88. Split Method string[] Split(Params char[] separator), string[] Split(char[] separator, int...
  89. StartsWith Method bool StartsWith(string value), bool StartsWith(string value, System.StringCom...
  90. Substring Method string Substring(int startIndex), string Substring(int startIndex, int length)
  91. ToBoolean Method bool IConvertible.ToBoolean(System.IFormatProvider provider)
  92. ToByte Method byte IConvertible.ToByte(System.IFormatProvider provider)
  93. ToChar Method char IConvertible.ToChar(System.IFormatProvider provider)
  94. ToCharArray Method char[] ToCharArray(), char[] ToCharArray(int startIndex, int length)
  95. ToDateTime Method datetime IConvertible.ToDateTime(System.IFormatProvider provider)
  96. ToDecimal Method decimal IConvertible.ToDecimal(System.IFormatProvider provider)
  97. ToDouble Method double IConvertible.ToDouble(System.IFormatProvider provider)
  98. ToInt16 Method int16 IConvertible.ToInt16(System.IFormatProvider provider)
  99. ToInt32 Method int IConvertible.ToInt32(System.IFormatProvider provider)
  100. ToInt64 Method long IConvertible.ToInt64(System.IFormatProvider provider)
  101. ToLower Method string ToLower(), string ToLower(cultureinfo culture)
  102. ToLowerInvariant Method string ToLowerInvariant()
  103. ToSByte Method sbyte IConvertible.ToSByte(System.IFormatProvider provider)
  104. ToSingle Method float IConvertible.ToSingle(System.IFormatProvider provider)
  105. ToString Method string ToString(), string ToString(System.IFormatProvider provider), string I...
  106. ToType Method System.Object IConvertible.ToType(type conversionType, System.IFormatProvider...
  107. ToUInt16 Method uint16 IConvertible.ToUInt16(System.IFormatProvider provider)
  108. ToUInt32 Method uint32 IConvertible.ToUInt32(System.IFormatProvider provider)
  109. ToUInt64 Method uint64 IConvertible.ToUInt64(System.IFormatProvider provider)
  110. ToUpper Method string ToUpper(), string ToUpper(cultureinfo culture)
  111. ToUpperInvariant Method string ToUpperInvariant()
  112. Trim Method string Trim(Params char[] trimChars), string Trim()
  113. TrimEnd Method string TrimEnd(Params char[] trimChars)
  114. TrimStart Method string TrimStart(Params char[] trimChars)
  115. Chars ParameterizedProperty char Chars(int index) {get;}
  116. Length Property int Length {get;}
  117.  
  118.  
  119. PS C:\Windows\system32> $a.foo | Get-Service
  120.  
  121. Status Name DisplayName
  122. ------ ---- -----------
  123. Running bits Background Intelligent Transfer Ser...
  124.  
  125.  
  126. PS C:\Windows\system32>
  127.  
  128.  
  129. TypeName: System.String
  130.  
  131. Name MemberType Definition
  132. ---- ---------- ----------
  133. Clone Method System.Object Clone(), System.Object ICloneable.Clone()
  134. CompareTo Method int CompareTo(System.Object value), int CompareTo(string strB), int IComparab...
  135. Contains Method bool Contains(string value)
  136. CopyTo Method void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int co...
  137. EndsWith Method bool EndsWith(string value), bool EndsWith(string value, System.StringCompari...
  138. Equals Method bool Equals(System.Object obj), bool Equals(string value), bool Equals(string...
  139. GetEnumerator Method System.CharEnumerator GetEnumerator(), System.Collections.Generic.IEnumerator...
  140. GetHashCode Method int GetHashCode()
  141. GetType Method type GetType()
  142. GetTypeCode Method System.TypeCode GetTypeCode(), System.TypeCode IConvertible.GetTypeCode()
  143. IndexOf Method int IndexOf(char value), int IndexOf(char value, int startIndex), int IndexOf...
  144. IndexOfAny Method int IndexOfAny(char[] anyOf), int IndexOfAny(char[] anyOf, int startIndex), i...
  145. Insert Method string Insert(int startIndex, string value)
  146. IsNormalized Method bool IsNormalized(), bool IsNormalized(System.Text.NormalizationForm normaliz...
  147. LastIndexOf Method int LastIndexOf(char value), int LastIndexOf(char value, int startIndex), int...
  148. LastIndexOfAny Method int LastIndexOfAny(char[] anyOf), int LastIndexOfAny(char[] anyOf, int startI...
  149. Normalize Method string Normalize(), string Normalize(System.Text.NormalizationForm normalizat...
  150. PadLeft Method string PadLeft(int totalWidth), string PadLeft(int totalWidth, char paddingChar)
  151. PadRight Method string PadRight(int totalWidth), string PadRight(int totalWidth, char padding...
  152. Remove Method string Remove(int startIndex, int count), string Remove(int startIndex)
  153. Replace Method string Replace(char oldChar, char newChar), string Replace(string oldValue, s...
  154. Split Method string[] Split(Params char[] separator), string[] Split(char[] separator, int...
  155. StartsWith Method bool StartsWith(string value), bool StartsWith(string value, System.StringCom...
  156. Substring Method string Substring(int startIndex), string Substring(int startIndex, int length)
  157. ToBoolean Method bool IConvertible.ToBoolean(System.IFormatProvider provider)
  158. ToByte Method byte IConvertible.ToByte(System.IFormatProvider provider)
  159. ToChar Method char IConvertible.ToChar(System.IFormatProvider provider)
  160. ToCharArray Method char[] ToCharArray(), char[] ToCharArray(int startIndex, int length)
  161. ToDateTime Method datetime IConvertible.ToDateTime(System.IFormatProvider provider)
  162. ToDecimal Method decimal IConvertible.ToDecimal(System.IFormatProvider provider)
  163. ToDouble Method double IConvertible.ToDouble(System.IFormatProvider provider)
  164. ToInt16 Method int16 IConvertible.ToInt16(System.IFormatProvider provider)
  165. ToInt32 Method int IConvertible.ToInt32(System.IFormatProvider provider)
  166. ToInt64 Method long IConvertible.ToInt64(System.IFormatProvider provider)
  167. ToLower Method string ToLower(), string ToLower(cultureinfo culture)
  168. ToLowerInvariant Method string ToLowerInvariant()
  169. ToSByte Method sbyte IConvertible.ToSByte(System.IFormatProvider provider)
  170. ToSingle Method float IConvertible.ToSingle(System.IFormatProvider provider)
  171. ToString Method string ToString(), string ToString(System.IFormatProvider provider), string I...
  172. ToType Method System.Object IConvertible.ToType(type conversionType, System.IFormatProvider...
  173. ToUInt16 Method uint16 IConvertible.ToUInt16(System.IFormatProvider provider)
  174. ToUInt32 Method uint32 IConvertible.ToUInt32(System.IFormatProvider provider)
  175. ToUInt64 Method uint64 IConvertible.ToUInt64(System.IFormatProvider provider)
  176. ToUpper Method string ToUpper(), string ToUpper(cultureinfo culture)
  177. ToUpperInvariant Method string ToUpperInvariant()
  178. Trim Method string Trim(Params char[] trimChars), string Trim()
  179. TrimEnd Method string TrimEnd(Params char[] trimChars)
  180. TrimStart Method string TrimStart(Params char[] trimChars)
  181. Chars ParameterizedProperty char Chars(int index) {get;}
  182. Length Property int Length {get;}
  183.  
  184.  
  185. PS C:\Windows\system32>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement