#navi(../)
* コマンドレットのメソッドやプロパティなどを調べる方法 [#gc5ac08d]
Get-Memberコマンドレットを利用することにより、コマンドレットのメソッドやプロパティを確認することができます。

#contents
#htmlinsertpcsp(win-top.html,win-sp.html)

* Get-Memberコマンドレットを使ってみる [#k1108fc4]
Get-Memberとパイプを使うことによりコマンドレットのメソッドやプロパティを確認することができます。~
以下、Get-Dateコマンドレットで試してみます。

- Get-Date | Get-Member 実行結果
 PS C:\Users\sakura> Get-Date | Get-Member
 
 
    TypeName: System.DateTime
 
 Name                 MemberType     Definition
 ----                 ----------     ----------
 Add                  Method         System.DateTime Add(System.TimeSpan value)
 AddDays              Method         System.DateTime AddDays(double value)
 AddHours             Method         System.DateTime AddHours(double value)
 AddMilliseconds      Method         System.DateTime AddMilliseconds(double value)
 AddMinutes           Method         System.DateTime AddMinutes(double value)
 AddMonths            Method         System.DateTime AddMonths(int months)
 AddSeconds           Method         System.DateTime AddSeconds(double value)
 AddTicks             Method         System.DateTime AddTicks(long value)
 AddYears             Method         System.DateTime AddYears(int value)
 CompareTo            Method         int CompareTo(System.Object value), int CompareTo(System.DateTime value)
 Equals               Method         bool Equals(System.Object value), bool Equals(System.DateTime value)
 GetDateTimeFormats   Method         string[] GetDateTimeFormats(), string[] GetDateTimeFormats(System.IFormatProvide...
 GetHashCode          Method         int GetHashCode()
 GetType              Method         type GetType()
 GetTypeCode          Method         System.TypeCode GetTypeCode()
 IsDaylightSavingTime Method         bool IsDaylightSavingTime()
 Subtract             Method         System.TimeSpan Subtract(System.DateTime value), System.DateTime Subtract(System...
 ToBinary             Method         long ToBinary()
 ToFileTime           Method         long ToFileTime()
 ToFileTimeUtc        Method         long ToFileTimeUtc()
 ToLocalTime          Method         System.DateTime ToLocalTime()
 ToLongDateString     Method         string ToLongDateString()
 ToLongTimeString     Method         string ToLongTimeString()
 ToOADate             Method         double ToOADate()
 ToShortDateString    Method         string ToShortDateString()
 ToShortTimeString    Method         string ToShortTimeString()
 ToString             Method         string ToString(), string ToString(string format), string ToString(System.IForma...
 ToUniversalTime      Method         System.DateTime ToUniversalTime()
 DisplayHint          NoteProperty   Microsoft.PowerShell.Commands.DisplayHintType DisplayHint=DateTime
 Date                 Property       System.DateTime Date {get;}
 Day                  Property       System.Int32 Day {get;}
 DayOfWeek            Property       System.DayOfWeek DayOfWeek {get;}
 DayOfYear            Property       System.Int32 DayOfYear {get;}
 Hour                 Property       System.Int32 Hour {get;}
 Kind                 Property       System.DateTimeKind Kind {get;}
 Millisecond          Property       System.Int32 Millisecond {get;}
 Minute               Property       System.Int32 Minute {get;}
 Month                Property       System.Int32 Month {get;}
 Second               Property       System.Int32 Second {get;}
 Ticks                Property       System.Int64 Ticks {get;}
 TimeOfDay            Property       System.TimeSpan TimeOfDay {get;}
 Year                 Property       System.Int32 Year {get;}
 DateTime             ScriptProperty System.Object DateTime {get=if ((& { Set-StrictMode -Version 1; $this.DisplayHin...

** Propertyの Year, Month, Day, Date を利用してみる。 [#n71df363]

 PS C:\Users\sakura> (Get-Date).Year
 2012
 PS C:\Users\sakura> (Get-Date).Month
 5
 PS C:\Users\sakura> (Get-Date).Day
 23
 PS C:\Users\sakura> (Get-Date).date
 
 2012年5月23日 0:00:00

** Method の ToString を利用してみる。 [#n730fb14]
 PS C:\Users\sakura> (Get-Date).ToString('yyyy-MM-dd')
 2012-05-23


以上、Get-MemberでGet-Dateが返却する.NET Frameworkのオブジェクト情報を調べる方法でした。

#htmlinsertpcsp(win-btm.html,win-sp.html)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS