1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Powershellに関する気づき集(じわじわ更新)

Posted at

バージョン

PS C:\Users\yoru_chin> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.26100.7462
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.26100.7462
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

[int]::?(2025/12/22)

ネットで拾ってきたPowerShellのスクリプトを見ていると、以下のようなコードで ん?となった。

[int] $NumberOfEvents = [int]::MaxValue

ということで調べてみた結果、[int]::はPowerShellで.NETのSystem.Int32型を使うための構文みたいです。

つまり、上の$NumberOfEventsには2147483647が入ることになります。

また、他に静的メンバーって何があるんやろ、と気になる時は[(型名)] | Get-Member -Staticで確認することができます。

PS C:\Users\yoru_chin> [int] | Get-Member -Static


   TypeName: System.Int32

Name            MemberType Definition
----            ---------- ----------
Equals          Method     static bool Equals(System.Object objA, System.Object objB)
Parse           Method     static int Parse(string s), static int Parse(string s, System.Globalization.NumberStyles style), static int Parse(string s, System.IFormatProvider provider), static int Parse(string s, System.Globalization.NumberStyles style, System.IFormatProvider provider)
ReferenceEquals Method     static bool ReferenceEquals(System.Object objA, System.Object objB)
TryParse        Method     static bool TryParse(string s, [ref] int result), static bool TryParse(string s, System.Globalization.NumberStyles style, System.IFormatProvider provider, [ref] int result)
MaxValue        Property   static int MaxValue {get;}
MinValue        Property   static int MinValue {get;}

すっきり!

参照

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?