PowerShell CoreÆþÌç - ´ðËÜ¥³¥Þ¥ó¥É¤Î»È¤¤Êý Âè178²ó PowerShell 7.2Åоì - ¥Õ¥¡¥¤¥ë¤È¿§ÀßÄê
¡û¼Â¸³Åªµ¡Ç½ - ¥Õ¥¡¥¤¥ë¤È¥«¥é¡¼ÀßÄê
PowerShell 7.2¤Ç¿·¤·¤¯Æ³Æþ¤µ¤ì¤¿¼Â¸³Åªµ¡Ç½¤Î1¤Ä¤Ë¡¢¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ë¥«¥é¡¼»ØÄê¤È¤¤¤¦µ¡Ç½¤¬¤¢¤ë¡£¤³¤Îµ¡Ç½¤Ï¡ÖPSAnsiRenderingFileInfo¡×¤È¸Æ¤Ð¤ì¤Æ¤ª¤ê¡¢°·¤¤¤¬´Êñ¤Ê¤ï¤ê¤Ë¸ú²Ì¤¬´üÂԤǤ¤ë¤Î¤Ç¡¢¤¼¤Ò°ìÅٻȤäƤߤƤ¤¤¿¤À¤¤¿¤¤¡£
¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï̵¸ú²½¤µ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢»È¤¦¾ì¹ç¤Ï¼¡¤Î¤è¤¦¤Ë¥³¥Þ¥ó¥É¥ì¥Ã¥È¤ò¼Â¹Ô¤·¤Æ¤«¤é¡¢PowerShell¤òºÆµ¯Æ°¤¹¤ëɬÍפ¬¤¢¤ë¡£
Enable-ExperimentalFeature -Name PSAnsiRenderingFileInfo
¤Ê¤ª¡¢Í¸ú²½¤·¤¿µ¡Ç½¤ò̵¸ú²½¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¥³¥Þ¥ó¥É¥ì¥Ã¥È¤ò¼Â¹Ô¤·¤Æ¤«¤éPowerShell¤òºÆµ¯Æ°¤¹¤ì¤Ð¤è¤¤¡£
Disable-ExperimentalFeature -Name PSAnsiRenderingFileInfo
PowerShell 7.2¤Ç¤Ï¥¿¡¼¥ß¥Ê¥ë¤Ë¤ª¤±¤ë¥«¥é¡¼É½¼¨µ¡Ç½¤¬¶¯²½¤µ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢PSAnsiRenderingFileInfo¤¬Í¸ú²½¤µ¤ì¤Æ¤¤¤ë¤Î¤«Ìµ¸ú²½¤µ¤ì¤Æ¤¤¤ë¤Î¤«¡¢¤è¤¯¤ï¤«¤é¤Ê¤¯¤Ê¤Ã¤Æ¤¯¤ë¤«¤â¤·¤ì¤Ê¤¤¡£¤½¤Î¾ì¹ç¡¢¼¡¤Î¤è¤¦¤Ë¥³¥Þ¥ó¥É¥ì¥Ã¥È¤ò¼Â¹Ô¤¹¤ì¤Ð¡¢Í¸ú¡¿Ìµ¸ú¤ò³Îǧ¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
PS C:\Users\daichi> Get-ExperimentalFeature -Name PSAnsiRenderingFileInfo | Format-List
Name : PSAnsiRenderingFileInfo
Enabled : True
Source : PSEngine
Description : Enable coloring for FileInfo objects
PS C:\Users\daichi>
¤Û¤«¤Ë¤â³ÎǧÊýË¡¤Ï¤¢¤ë¡£Î㤨¤Ð¡¢PSAnsiRenderingFileInfo¤¬Ìµ¸ú²½¤µ¤ì¤¿¾õÂ֤ǡÖdir¡×¤ò¼Â¹Ô¤¹¤ë¤È¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£¥Ç¥£¥ì¥¯¥È¥ê¤Ë¿§¤ÏÃ夤¤Æ¤¤¤Ê¤¤¡£
¤³¤ì¤¬¡¢PSAnsiRenderingFileInfo¤ò͸ú²½¤·¤¿¾õÂÖ¤À¤È¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£
¥Ç¥£¥ì¥¯¥È¥ê¤Îɽ¼¨¤¬ÊѤï¤Ã¤Æ¤¤¤ë¤³¤È¤¬¤ª¤ï¤«¤ê¤¤¤¿¤À¤±¤ë¤À¤í¤¦¡£ÀÄÃϤËÇò¤Çɽ¼¨¤µ¤ì¤Æ¤¤¤ë¡£¤³¤ì¤¬PSAnsiRenderingFileInfo¤Îµ¡Ç½¤À¡£
Mac¤äLinux¤Ç¤Ï¥·¥§¥ë¤äls¥³¥Þ¥ó¥É¤¬¸Ä¡¹¤Ë¥«¥é¡¼É½¼¨µ¡Ç½¤ò»ý¤Ã¤Æ¤ª¤ê¡¢¤½¤ì¤¾¤ì¤ËÀßÄêÊýË¡¤ä͸ú²½¤ÎÊýË¡¤¬°Û¤Ê¤Ã¤Æ¤¤¤ë¡£´Ä¶ÊÑ¿ô¤äÊÑ¿ô¤Ç¤Î¿§»ØÄê¡¢¤½¤ì¤Ë͸ú²½¤¹¤ë¤¿¤á¤Î¥ª¥×¥·¥ç¥ó»ØÄê¤ä´Ä¶ÊÑ¿ôÀßÄê¤Ê¤É¤À¡£É½¼¨¤µ¤ì¤ë¿§¤ò¤½¤í¤¨¤ë¤Ë¤Ï¡¢¤½¤ì¤é¤ò¸ÄÊ̤ËÁ´ÉôÀßÄꤹ¤ëɬÍפ¬¤¢¤ë¡£
PowerShell¤Î¾ì¹ç¤ÏPowerShell¤¬µ¡Ç½¤ò»ý¤Ä¤³¤È¤Ë¤Ê¤ë¤ï¤±¤À¤¬¡¢dir¤Ê¤É¤â¼ÂºÝ¤Ë¤ÏPowerShell¤Î¥³¥Þ¥ó¥É¥ì¥Ã¥È¤Ø¤Î¥¨¥¤¥ê¥¢¥¹¤Ç¤¢¤ê¡¢PowerShell¼«ÂΤ¬Ä󶡤·¤Æ¤¤¤ëµ¡Ç½¤À¡£PSAnsiRenderingFileInfo¤Ë¤è¤Ã¤Æ¤µ¤Þ¤¶¤Þ¤Ê¥³¥Þ¥ó¥É¥ì¥Ã¥È¤ÎµóÆ°¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤ë¤â¤Î¤È¸«¤é¤ì¤ë¡£
¡û$PSStyle.FileInfo
PowerShell 7.2¤Ç¤Ï¡Ö$PSStyle¡×¤Ç¤µ¤Þ¤¶¤Þ¤Ê¿§¤¬ÀßÄê¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£¼¡¤Î¤è¤¦¤Ë$PSStyle¤Î¥á¥ó¥Ð¡¼¤ò³Îǧ¤¹¤ë¤È¡¢¥Õ¥©¥ó¥È¤ª¤è¤Ó¥«¥é¡¼¤Ë´Ø¤¹¤ëÀßÄê¾ðÊó¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤ò³Îǧ¤Ç¤¤ë¡£
PS C:\Users\daichi> $PSStyle | Get-Member
TypeName: System.Management.Automation.PSStyle
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
FormatHyperlink Method string FormatHyperlink(string text, uri link)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Background Property System.Management.Automation.PSStyle+BackgroundColor Background {get;}
Blink Property string Blink {get;}
BlinkOff Property string BlinkOff {get;}
Bold Property string Bold {get;}
BoldOff Property string BoldOff {get;}
FileInfo Property System.Management.Automation.PSStyle+FileInfoFormatting FileInfo {get;}
Foreground Property System.Management.Automation.PSStyle+ForegroundColor Foreground {get;}
Formatting Property System.Management.Automation.PSStyle+FormattingData Formatting {get;}
Hidden Property string Hidden {get;}
HiddenOff Property string HiddenOff {get;}
Italic Property string Italic {get;}
ItalicOff Property string ItalicOff {get;}
OutputRendering Property System.Management.Automation.OutputRendering OutputRendering {get;set;}
Progress Property System.Management.Automation.PSStyle+ProgressConfiguration Progress {get;}
Reset Property string Reset {get;}
Reverse Property string Reverse {get;}
ReverseOff Property string ReverseOff {get;}
Strikethrough Property string Strikethrough {get;}
StrikethroughOff Property string StrikethroughOff {get;}
Underline Property string Underline {get;}
UnderlineOff Property string UnderlineOff {get;}
PS C:\Users\daichi>
PSAnsiRenderingFileInfo¤Ç»È¤ï¤ì¤ë¡Ö$PSStyle.FileInfo¡×¤Ï¾åµ¥³¥Þ¥ó¥É¥ì¥Ã¥È¤Ç³Îǧ¤Ç¤¤ë¤è¤¦¤Ë$PSStyle¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¡£$PSStyle.FileInfo¤Î¥á¥ó¥Ð¡¼¤ò³Îǧ¤¹¤ë¤È¡¢¼¡¤Î¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
PS C:\Users\daichi> $PSStyle.FileInfo | Get-Member
TypeName: System.Management.Automation.PSStyle+FileInfoFormatting
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Directory Property string Directory {get;set;}
Executable Property string Executable {get;set;}
Extension Property System.Management.Automation.PSStyle+FileInfoFormatting+FileExtensionDictionary Extension {get;}
SymbolicLink Property string SymbolicLink {get;set;}
PS C:\Users\daichi>
¥×¥í¥Ñ¥Æ¥£¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ë¤Î¤¬¡¢ÍøÍѤǤ¤ë¼Â¸³Åªµ¡Ç½¤À¡£À°Íý¤¹¤ë¤È¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£
Î㤨¤Ð¡¢¡Ö$PSStyle.FileInfo.Directory¡×¤Ï¥Ç¥£¥ì¥¯¥È¥ê¤Î¿§¤ò»ØÄꤹ¤ë¤â¤Î¤Ç¡¢Ä´¤Ù¤Æ¤ß¤ë¤È¼¡¤Î¤è¤¦¤Ëʸ»úÎó¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¤¬¤ï¤«¤ë¡£
PS C:\Users\daichi> $PSStyle.FileInfo.Directory | Get-Member
TypeName: System.String
Name MemberType Definition
---- ---------- ----------
Clone Method System.Object Clone(), System.Object ICloneable.Clone()
CompareTo Method int CompareTo(System.Object value), int CompareTo(string strB), int IComparable.Com¡Ä
Contains Method bool Contains(string value), bool Contains(string value, System.StringComparison co¡Ä
CopyTo Method void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count), ¡Ä
EndsWith Method bool EndsWith(string value), bool EndsWith(string value, System.StringComparison co¡Ä
EnumerateRunes Method System.Text.StringRuneEnumerator EnumerateRunes()
Equals Method bool Equals(System.Object obj), bool Equals(string value), bool Equals(string value¡Ä
GetEnumerator Method System.CharEnumerator GetEnumerator(), System.Collections.IEnumerator IEnumerable.G¡Ä
GetHashCode Method int GetHashCode(), int GetHashCode(System.StringComparison comparisonType)
GetPinnableReference Method System.Char&, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyTo¡Ä
GetType Method type GetType()
GetTypeCode Method System.TypeCode GetTypeCode(), System.TypeCode IConvertible.GetTypeCode()
IndexOf Method int IndexOf(char value), int IndexOf(char value, int startIndex), int IndexOf(char ¡Ä
IndexOfAny Method int IndexOfAny(char[] anyOf), int IndexOfAny(char[] anyOf, int startIndex), int Ind¡Ä
Insert Method string Insert(int startIndex, string value)
IsNormalized Method bool IsNormalized(), bool IsNormalized(System.Text.NormalizationForm normalizationF¡Ä
LastIndexOf Method int LastIndexOf(string value, int startIndex), int LastIndexOf(string value, int st¡Ä
LastIndexOfAny Method int LastIndexOfAny(char[] anyOf), int LastIndexOfAny(char[] anyOf, int startIndex),¡Ä
Normalize Method string Normalize(), string Normalize(System.Text.NormalizationForm normalizationFor¡Ä
PadLeft Method string PadLeft(int totalWidth), string PadLeft(int totalWidth, char paddingChar)
PadRight Method string PadRight(int totalWidth), string PadRight(int totalWidth, char paddingChar)
Remove Method string Remove(int startIndex, int count), string Remove(int startIndex)
Replace Method string Replace(string oldValue, string newValue, bool ignoreCase, cultureinfo cultu¡Ä
ReplaceLineEndings Method string ReplaceLineEndings(), string ReplaceLineEndings(string replacementText)
Split Method string[] Split(char separator, System.StringSplitOptions options), string[] Split(c¡Ä
StartsWith Method bool StartsWith(string value), bool StartsWith(string value, System.StringCompariso¡Ä
Substring Method string Substring(int startIndex), string Substring(int startIndex, int length)
ToBoolean Method bool IConvertible.ToBoolean(System.IFormatProvider provider)
ToByte Method byte IConvertible.ToByte(System.IFormatProvider provider)
ToChar Method char IConvertible.ToChar(System.IFormatProvider provider)
ToCharArray Method char[] ToCharArray(), char[] ToCharArray(int startIndex, int length)
ToDateTime Method datetime IConvertible.ToDateTime(System.IFormatProvider provider)
ToDecimal Method decimal IConvertible.ToDecimal(System.IFormatProvider provider)
ToDouble Method double IConvertible.ToDouble(System.IFormatProvider provider)
ToInt16 Method short IConvertible.ToInt16(System.IFormatProvider provider)
ToInt32 Method int IConvertible.ToInt32(System.IFormatProvider provider)
ToInt64 Method long IConvertible.ToInt64(System.IFormatProvider provider)
ToLower Method string ToLower(), string ToLower(cultureinfo culture)
ToLowerInvariant Method string ToLowerInvariant()
ToSByte Method sbyte IConvertible.ToSByte(System.IFormatProvider provider)
ToSingle Method float IConvertible.ToSingle(System.IFormatProvider provider)
ToString Method string ToString(), string ToString(System.IFormatProvider provider), string IConver¡Ä
ToType Method System.Object IConvertible.ToType(type conversionType, System.IFormatProvider provi¡Ä
ToUInt16 Method ushort IConvertible.ToUInt16(System.IFormatProvider provider)
ToUInt32 Method uint IConvertible.ToUInt32(System.IFormatProvider provider)
ToUInt64 Method ulong IConvertible.ToUInt64(System.IFormatProvider provider)
ToUpper Method string ToUpper(), string ToUpper(cultureinfo culture)
ToUpperInvariant Method string ToUpperInvariant()
Trim Method string Trim(), string Trim(char trimChar), string Trim(Params char[] trimChars)
TrimEnd Method string TrimEnd(), string TrimEnd(char trimChar), string TrimEnd(Params char[] trimC¡Ä
TrimStart Method string TrimStart(), string TrimStart(char trimChar), string TrimStart(Params char[]¡Ä
TryCopyTo Method bool TryCopyTo(System.Span[char] destination)
Chars ParameterizedProperty char Chars(int index) {get;}
Length Property int Length {get;}
PS C:\Users\daichi>
¤Ä¤Þ¤ê¡¢$PSStyle.FileInfo.Directory¤Ëʸ»úÎó¤Ç¿§¤ò»ØÄꤷ¤Æ»È¤¦¤È¤¤¤¦¤³¤È¤Ë¤Ê¤ë¡£
¡ûÁ°·Ê¿§¤ÈÇØ·Ê¿§¤Î»ØÄê
¤Ç¤ÏľÀÜ¿§¤òʸ»úÎó¤Ç»ØÄꤹ¤ë¤Î¤«¤È¸À¤¦¤È¡¢¤½¤¦¤Ç¤Ï¤Ê¤¤¡£$PSStyle¤ËÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¿§»ØÄê¤Ç¤¢¤ë¡Ö$PSStyle.Foreground¡×¤È¡Ö$PSStyle.Background¡×¤ò»È¤¦»ÅÁȤߤˤʤäƤ¤¤ë¡£¤½¤ì¤¾¤ì¤Î¥á¥ó¥Ð¡¼¤Ï¼¡¤Î¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
$PSStyle.Foreground¤Î¥á¥ó¥Ð¡¼¤òɽ¼¨
PS C:\Users\daichi\Documents\powershell\20211204> $PSStyle.Foreground | Get-Member
TypeName: System.Management.Automation.PSStyle+ForegroundColor
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
FromRgb Method string FromRgb(byte red, byte green, byte blue), string FromRgb(int rgb)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Black Property string Black {get;}
Blue Property string Blue {get;}
BrightBlack Property string BrightBlack {get;}
BrightBlue Property string BrightBlue {get;}
BrightCyan Property string BrightCyan {get;}
BrightGreen Property string BrightGreen {get;}
BrightMagenta Property string BrightMagenta {get;}
BrightRed Property string BrightRed {get;}
BrightWhite Property string BrightWhite {get;}
BrightYellow Property string BrightYellow {get;}
Cyan Property string Cyan {get;}
Green Property string Green {get;}
Magenta Property string Magenta {get;}
Red Property string Red {get;}
White Property string White {get;}
Yellow Property string Yellow {get;}
PS C:\Users\daichi\Documents\powershell\20211204>
$PSStyle.Background¤Î¥á¥ó¥Ð¡¼¤òɽ¼¨
PS C:\Users\daichi\Documents\powershell\20211204> $PSStyle.Background | Get-Member
TypeName: System.Management.Automation.PSStyle+BackgroundColor
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
FromRgb Method string FromRgb(byte red, byte green, byte blue), string FromRgb(int rgb)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Black Property string Black {get;}
Blue Property string Blue {get;}
BrightBlack Property string BrightBlack {get;}
BrightBlue Property string BrightBlue {get;}
BrightCyan Property string BrightCyan {get;}
BrightGreen Property string BrightGreen {get;}
BrightMagenta Property string BrightMagenta {get;}
BrightRed Property string BrightRed {get;}
BrightWhite Property string BrightWhite {get;}
BrightYellow Property string BrightYellow {get;}
Cyan Property string Cyan {get;}
Green Property string Green {get;}
Magenta Property string Magenta {get;}
Red Property string Red {get;}
White Property string White {get;}
Yellow Property string Yellow {get;}
PS C:\Users\daichi\Documents\powershell\20211204>
¤³¤ì¤òÀ°Íý¤¹¤ë¤È¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£
FromRgb¥á¥½¥Ã¥É¤ò»È¤¨¤Ð¤«¤Ê¤êºÙ¤«¤¯¿§¤ò»ØÄꤹ¤ë¤³¤È¤â¤Ç¤¤ë¤¬¡¢ºÇ½é¤ÏÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¡ÖRed¡×¤ä¡ÖBlue¡×¡¢¡ÖGreen¡×¤È¤¤¤Ã¤¿¥Ç¥Õ¥©¥ë¥È¤Î¿§¤Ç½½Ê¬¤À¤í¤¦¡£
¡û»È¤Ã¤Æ¤ß¤è¤¦
¤Ç¤ÏÁᮡ¢»È¤Ã¤Æ¤ß¤è¤¦¡£»È¤¤Êý¤Ï´Êñ¤À¡£PSAnsiRenderingFileInfo¤ò͸ú²½¤·¤¿¾õÂ֤ǡ¢¿§¤òÀßÄꤹ¤ì¤Ð¤è¤¤¡£¥Ç¥£¥ì¥¯¥È¥ê¤ÎÁ°·Ê¿§¤òÀ֤ˤ¹¤ë¤Î¤Ç¤¢¤ì¤Ð¡¢¼¡¤Î¤è¤¦¤ËÀßÄꤹ¤ë¡£
$PSStyle.FileInfo.Directory = $PSStyle.Foreground.Red
¼Â¹Ô¤¹¤ë¤È¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£¥Ç¥£¥ì¥¯¥È¥ê¤¬ÀÖ¤Çɽ¼¨¤µ¤ì¤Æ¤¤¤ë¤³¤È¤ò³Îǧ¤Ç¤¤ë¤È»×¤¦¡£
Á°·Ê¿§¤ÈÇØ·Ê¿§¤òƱ»þ¤Ë»ØÄꤹ¤ë¾ì¹ç¤Ï¼¡¤Î¤è¤¦¤Ë¤¹¤ë¡£
$PSStyle.FileInfo.Directory = $PSStyle.Foreground.White + $PSStyle.Background.Blue
¥«¥é¡¼É½¼¨¤Ï»ëǧÀ¤ò¹â¤á¤ë¾å¤ÇÌò¤ËΩ¤Ä¡£ÀßÄê¤òÊѹ¹¤·¤Æ¡¢ÉáÃʻȤäƤ¤¤ëLinux¤Î¥·¥§¥ë¤äls¥³¥Þ¥ó¥É¤Î¿§ÀßÄê¤ÈPowerShell¤Î¿§ÀßÄê¤ò¤½¤í¤¨¤Æ¤ª¤¯¤È¡¢°ãÏ´¶¤Ê¤¯»È¤¦¤³¤È¤¬¤Ç¤¤ë¤Ï¤º¤À¡£
¤Þ¤À¼Â¸³Ãʳ¬¤Ç¤Ï¤¢¤ë¤¬¡¢ÊØÍø¤Êµ¡Ç½¤Ç¤¢¤ê¡¢¥Ç¥Õ¥©¥ë¥ÈºÎÍѤòÁ˳²¤¹¤ëÂ礤ÊÍ×°ø¤¬¤¢¤ë¤È¤â»×¤¨¤Ê¤¤¤Î¤Ç¡¢¤¤¤º¤ì¥Ç¥Õ¥©¥ë¥È¤Îµ¡Ç½¤È¤·¤Æ»È¤¨¤ë¤è¤¦¤Ë¤Ê¤ë¤Î¤Ç¤Ï¤Ê¤¤¤À¤í¤¦¤«¡£
¡û»²¹Í
What's New in PowerShell 7.2 - PowerShell | Microsoft Docs
Using Experimental Features in PowerShell - PowerShell | Microsoft Docs
PowerShell 7.2¤Ç¿·¤·¤¯Æ³Æþ¤µ¤ì¤¿¼Â¸³Åªµ¡Ç½¤Î1¤Ä¤Ë¡¢¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ë¥«¥é¡¼»ØÄê¤È¤¤¤¦µ¡Ç½¤¬¤¢¤ë¡£¤³¤Îµ¡Ç½¤Ï¡ÖPSAnsiRenderingFileInfo¡×¤È¸Æ¤Ð¤ì¤Æ¤ª¤ê¡¢°·¤¤¤¬´Êñ¤Ê¤ï¤ê¤Ë¸ú²Ì¤¬´üÂԤǤ¤ë¤Î¤Ç¡¢¤¼¤Ò°ìÅٻȤäƤߤƤ¤¤¿¤À¤¤¿¤¤¡£
¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï̵¸ú²½¤µ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢»È¤¦¾ì¹ç¤Ï¼¡¤Î¤è¤¦¤Ë¥³¥Þ¥ó¥É¥ì¥Ã¥È¤ò¼Â¹Ô¤·¤Æ¤«¤é¡¢PowerShell¤òºÆµ¯Æ°¤¹¤ëɬÍפ¬¤¢¤ë¡£
¤Ê¤ª¡¢Í¸ú²½¤·¤¿µ¡Ç½¤ò̵¸ú²½¤¹¤ë¤Ë¤Ï¡¢¼¡¤Î¤è¤¦¤Ë¥³¥Þ¥ó¥É¥ì¥Ã¥È¤ò¼Â¹Ô¤·¤Æ¤«¤éPowerShell¤òºÆµ¯Æ°¤¹¤ì¤Ð¤è¤¤¡£
Disable-ExperimentalFeature -Name PSAnsiRenderingFileInfo
PowerShell 7.2¤Ç¤Ï¥¿¡¼¥ß¥Ê¥ë¤Ë¤ª¤±¤ë¥«¥é¡¼É½¼¨µ¡Ç½¤¬¶¯²½¤µ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢PSAnsiRenderingFileInfo¤¬Í¸ú²½¤µ¤ì¤Æ¤¤¤ë¤Î¤«Ìµ¸ú²½¤µ¤ì¤Æ¤¤¤ë¤Î¤«¡¢¤è¤¯¤ï¤«¤é¤Ê¤¯¤Ê¤Ã¤Æ¤¯¤ë¤«¤â¤·¤ì¤Ê¤¤¡£¤½¤Î¾ì¹ç¡¢¼¡¤Î¤è¤¦¤Ë¥³¥Þ¥ó¥É¥ì¥Ã¥È¤ò¼Â¹Ô¤¹¤ì¤Ð¡¢Í¸ú¡¿Ìµ¸ú¤ò³Îǧ¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
PS C:\Users\daichi> Get-ExperimentalFeature -Name PSAnsiRenderingFileInfo | Format-List
Name : PSAnsiRenderingFileInfo
Enabled : True
Source : PSEngine
Description : Enable coloring for FileInfo objects
PS C:\Users\daichi>
¤Û¤«¤Ë¤â³ÎǧÊýË¡¤Ï¤¢¤ë¡£Î㤨¤Ð¡¢PSAnsiRenderingFileInfo¤¬Ìµ¸ú²½¤µ¤ì¤¿¾õÂ֤ǡÖdir¡×¤ò¼Â¹Ô¤¹¤ë¤È¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£¥Ç¥£¥ì¥¯¥È¥ê¤Ë¿§¤ÏÃ夤¤Æ¤¤¤Ê¤¤¡£
¤³¤ì¤¬¡¢PSAnsiRenderingFileInfo¤ò͸ú²½¤·¤¿¾õÂÖ¤À¤È¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£
¥Ç¥£¥ì¥¯¥È¥ê¤Îɽ¼¨¤¬ÊѤï¤Ã¤Æ¤¤¤ë¤³¤È¤¬¤ª¤ï¤«¤ê¤¤¤¿¤À¤±¤ë¤À¤í¤¦¡£ÀÄÃϤËÇò¤Çɽ¼¨¤µ¤ì¤Æ¤¤¤ë¡£¤³¤ì¤¬PSAnsiRenderingFileInfo¤Îµ¡Ç½¤À¡£
Mac¤äLinux¤Ç¤Ï¥·¥§¥ë¤äls¥³¥Þ¥ó¥É¤¬¸Ä¡¹¤Ë¥«¥é¡¼É½¼¨µ¡Ç½¤ò»ý¤Ã¤Æ¤ª¤ê¡¢¤½¤ì¤¾¤ì¤ËÀßÄêÊýË¡¤ä͸ú²½¤ÎÊýË¡¤¬°Û¤Ê¤Ã¤Æ¤¤¤ë¡£´Ä¶ÊÑ¿ô¤äÊÑ¿ô¤Ç¤Î¿§»ØÄê¡¢¤½¤ì¤Ë͸ú²½¤¹¤ë¤¿¤á¤Î¥ª¥×¥·¥ç¥ó»ØÄê¤ä´Ä¶ÊÑ¿ôÀßÄê¤Ê¤É¤À¡£É½¼¨¤µ¤ì¤ë¿§¤ò¤½¤í¤¨¤ë¤Ë¤Ï¡¢¤½¤ì¤é¤ò¸ÄÊ̤ËÁ´ÉôÀßÄꤹ¤ëɬÍפ¬¤¢¤ë¡£
PowerShell¤Î¾ì¹ç¤ÏPowerShell¤¬µ¡Ç½¤ò»ý¤Ä¤³¤È¤Ë¤Ê¤ë¤ï¤±¤À¤¬¡¢dir¤Ê¤É¤â¼ÂºÝ¤Ë¤ÏPowerShell¤Î¥³¥Þ¥ó¥É¥ì¥Ã¥È¤Ø¤Î¥¨¥¤¥ê¥¢¥¹¤Ç¤¢¤ê¡¢PowerShell¼«ÂΤ¬Ä󶡤·¤Æ¤¤¤ëµ¡Ç½¤À¡£PSAnsiRenderingFileInfo¤Ë¤è¤Ã¤Æ¤µ¤Þ¤¶¤Þ¤Ê¥³¥Þ¥ó¥É¥ì¥Ã¥È¤ÎµóÆ°¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤ë¤â¤Î¤È¸«¤é¤ì¤ë¡£
¡û$PSStyle.FileInfo
PowerShell 7.2¤Ç¤Ï¡Ö$PSStyle¡×¤Ç¤µ¤Þ¤¶¤Þ¤Ê¿§¤¬ÀßÄê¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£¼¡¤Î¤è¤¦¤Ë$PSStyle¤Î¥á¥ó¥Ð¡¼¤ò³Îǧ¤¹¤ë¤È¡¢¥Õ¥©¥ó¥È¤ª¤è¤Ó¥«¥é¡¼¤Ë´Ø¤¹¤ëÀßÄê¾ðÊó¤ò»ý¤Ã¤Æ¤¤¤ë¤³¤È¤ò³Îǧ¤Ç¤¤ë¡£
PS C:\Users\daichi> $PSStyle | Get-Member
TypeName: System.Management.Automation.PSStyle
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
FormatHyperlink Method string FormatHyperlink(string text, uri link)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Background Property System.Management.Automation.PSStyle+BackgroundColor Background {get;}
Blink Property string Blink {get;}
BlinkOff Property string BlinkOff {get;}
Bold Property string Bold {get;}
BoldOff Property string BoldOff {get;}
FileInfo Property System.Management.Automation.PSStyle+FileInfoFormatting FileInfo {get;}
Foreground Property System.Management.Automation.PSStyle+ForegroundColor Foreground {get;}
Formatting Property System.Management.Automation.PSStyle+FormattingData Formatting {get;}
Hidden Property string Hidden {get;}
HiddenOff Property string HiddenOff {get;}
Italic Property string Italic {get;}
ItalicOff Property string ItalicOff {get;}
OutputRendering Property System.Management.Automation.OutputRendering OutputRendering {get;set;}
Progress Property System.Management.Automation.PSStyle+ProgressConfiguration Progress {get;}
Reset Property string Reset {get;}
Reverse Property string Reverse {get;}
ReverseOff Property string ReverseOff {get;}
Strikethrough Property string Strikethrough {get;}
StrikethroughOff Property string StrikethroughOff {get;}
Underline Property string Underline {get;}
UnderlineOff Property string UnderlineOff {get;}
PS C:\Users\daichi>
PSAnsiRenderingFileInfo¤Ç»È¤ï¤ì¤ë¡Ö$PSStyle.FileInfo¡×¤Ï¾åµ¥³¥Þ¥ó¥É¥ì¥Ã¥È¤Ç³Îǧ¤Ç¤¤ë¤è¤¦¤Ë$PSStyle¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¡£$PSStyle.FileInfo¤Î¥á¥ó¥Ð¡¼¤ò³Îǧ¤¹¤ë¤È¡¢¼¡¤Î¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
PS C:\Users\daichi> $PSStyle.FileInfo | Get-Member
TypeName: System.Management.Automation.PSStyle+FileInfoFormatting
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Directory Property string Directory {get;set;}
Executable Property string Executable {get;set;}
Extension Property System.Management.Automation.PSStyle+FileInfoFormatting+FileExtensionDictionary Extension {get;}
SymbolicLink Property string SymbolicLink {get;set;}
PS C:\Users\daichi>
¥×¥í¥Ñ¥Æ¥£¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ë¤Î¤¬¡¢ÍøÍѤǤ¤ë¼Â¸³Åªµ¡Ç½¤À¡£À°Íý¤¹¤ë¤È¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£
Î㤨¤Ð¡¢¡Ö$PSStyle.FileInfo.Directory¡×¤Ï¥Ç¥£¥ì¥¯¥È¥ê¤Î¿§¤ò»ØÄꤹ¤ë¤â¤Î¤Ç¡¢Ä´¤Ù¤Æ¤ß¤ë¤È¼¡¤Î¤è¤¦¤Ëʸ»úÎó¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¤¬¤ï¤«¤ë¡£
PS C:\Users\daichi> $PSStyle.FileInfo.Directory | Get-Member
TypeName: System.String
Name MemberType Definition
---- ---------- ----------
Clone Method System.Object Clone(), System.Object ICloneable.Clone()
CompareTo Method int CompareTo(System.Object value), int CompareTo(string strB), int IComparable.Com¡Ä
Contains Method bool Contains(string value), bool Contains(string value, System.StringComparison co¡Ä
CopyTo Method void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count), ¡Ä
EndsWith Method bool EndsWith(string value), bool EndsWith(string value, System.StringComparison co¡Ä
EnumerateRunes Method System.Text.StringRuneEnumerator EnumerateRunes()
Equals Method bool Equals(System.Object obj), bool Equals(string value), bool Equals(string value¡Ä
GetEnumerator Method System.CharEnumerator GetEnumerator(), System.Collections.IEnumerator IEnumerable.G¡Ä
GetHashCode Method int GetHashCode(), int GetHashCode(System.StringComparison comparisonType)
GetPinnableReference Method System.Char&, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyTo¡Ä
GetType Method type GetType()
GetTypeCode Method System.TypeCode GetTypeCode(), System.TypeCode IConvertible.GetTypeCode()
IndexOf Method int IndexOf(char value), int IndexOf(char value, int startIndex), int IndexOf(char ¡Ä
IndexOfAny Method int IndexOfAny(char[] anyOf), int IndexOfAny(char[] anyOf, int startIndex), int Ind¡Ä
Insert Method string Insert(int startIndex, string value)
IsNormalized Method bool IsNormalized(), bool IsNormalized(System.Text.NormalizationForm normalizationF¡Ä
LastIndexOf Method int LastIndexOf(string value, int startIndex), int LastIndexOf(string value, int st¡Ä
LastIndexOfAny Method int LastIndexOfAny(char[] anyOf), int LastIndexOfAny(char[] anyOf, int startIndex),¡Ä
Normalize Method string Normalize(), string Normalize(System.Text.NormalizationForm normalizationFor¡Ä
PadLeft Method string PadLeft(int totalWidth), string PadLeft(int totalWidth, char paddingChar)
PadRight Method string PadRight(int totalWidth), string PadRight(int totalWidth, char paddingChar)
Remove Method string Remove(int startIndex, int count), string Remove(int startIndex)
Replace Method string Replace(string oldValue, string newValue, bool ignoreCase, cultureinfo cultu¡Ä
ReplaceLineEndings Method string ReplaceLineEndings(), string ReplaceLineEndings(string replacementText)
Split Method string[] Split(char separator, System.StringSplitOptions options), string[] Split(c¡Ä
StartsWith Method bool StartsWith(string value), bool StartsWith(string value, System.StringCompariso¡Ä
Substring Method string Substring(int startIndex), string Substring(int startIndex, int length)
ToBoolean Method bool IConvertible.ToBoolean(System.IFormatProvider provider)
ToByte Method byte IConvertible.ToByte(System.IFormatProvider provider)
ToChar Method char IConvertible.ToChar(System.IFormatProvider provider)
ToCharArray Method char[] ToCharArray(), char[] ToCharArray(int startIndex, int length)
ToDateTime Method datetime IConvertible.ToDateTime(System.IFormatProvider provider)
ToDecimal Method decimal IConvertible.ToDecimal(System.IFormatProvider provider)
ToDouble Method double IConvertible.ToDouble(System.IFormatProvider provider)
ToInt16 Method short IConvertible.ToInt16(System.IFormatProvider provider)
ToInt32 Method int IConvertible.ToInt32(System.IFormatProvider provider)
ToInt64 Method long IConvertible.ToInt64(System.IFormatProvider provider)
ToLower Method string ToLower(), string ToLower(cultureinfo culture)
ToLowerInvariant Method string ToLowerInvariant()
ToSByte Method sbyte IConvertible.ToSByte(System.IFormatProvider provider)
ToSingle Method float IConvertible.ToSingle(System.IFormatProvider provider)
ToString Method string ToString(), string ToString(System.IFormatProvider provider), string IConver¡Ä
ToType Method System.Object IConvertible.ToType(type conversionType, System.IFormatProvider provi¡Ä
ToUInt16 Method ushort IConvertible.ToUInt16(System.IFormatProvider provider)
ToUInt32 Method uint IConvertible.ToUInt32(System.IFormatProvider provider)
ToUInt64 Method ulong IConvertible.ToUInt64(System.IFormatProvider provider)
ToUpper Method string ToUpper(), string ToUpper(cultureinfo culture)
ToUpperInvariant Method string ToUpperInvariant()
Trim Method string Trim(), string Trim(char trimChar), string Trim(Params char[] trimChars)
TrimEnd Method string TrimEnd(), string TrimEnd(char trimChar), string TrimEnd(Params char[] trimC¡Ä
TrimStart Method string TrimStart(), string TrimStart(char trimChar), string TrimStart(Params char[]¡Ä
TryCopyTo Method bool TryCopyTo(System.Span[char] destination)
Chars ParameterizedProperty char Chars(int index) {get;}
Length Property int Length {get;}
PS C:\Users\daichi>
¤Ä¤Þ¤ê¡¢$PSStyle.FileInfo.Directory¤Ëʸ»úÎó¤Ç¿§¤ò»ØÄꤷ¤Æ»È¤¦¤È¤¤¤¦¤³¤È¤Ë¤Ê¤ë¡£
¡ûÁ°·Ê¿§¤ÈÇØ·Ê¿§¤Î»ØÄê
¤Ç¤ÏľÀÜ¿§¤òʸ»úÎó¤Ç»ØÄꤹ¤ë¤Î¤«¤È¸À¤¦¤È¡¢¤½¤¦¤Ç¤Ï¤Ê¤¤¡£$PSStyle¤ËÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¿§»ØÄê¤Ç¤¢¤ë¡Ö$PSStyle.Foreground¡×¤È¡Ö$PSStyle.Background¡×¤ò»È¤¦»ÅÁȤߤˤʤäƤ¤¤ë¡£¤½¤ì¤¾¤ì¤Î¥á¥ó¥Ð¡¼¤Ï¼¡¤Î¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
$PSStyle.Foreground¤Î¥á¥ó¥Ð¡¼¤òɽ¼¨
PS C:\Users\daichi\Documents\powershell\20211204> $PSStyle.Foreground | Get-Member
TypeName: System.Management.Automation.PSStyle+ForegroundColor
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
FromRgb Method string FromRgb(byte red, byte green, byte blue), string FromRgb(int rgb)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Black Property string Black {get;}
Blue Property string Blue {get;}
BrightBlack Property string BrightBlack {get;}
BrightBlue Property string BrightBlue {get;}
BrightCyan Property string BrightCyan {get;}
BrightGreen Property string BrightGreen {get;}
BrightMagenta Property string BrightMagenta {get;}
BrightRed Property string BrightRed {get;}
BrightWhite Property string BrightWhite {get;}
BrightYellow Property string BrightYellow {get;}
Cyan Property string Cyan {get;}
Green Property string Green {get;}
Magenta Property string Magenta {get;}
Red Property string Red {get;}
White Property string White {get;}
Yellow Property string Yellow {get;}
PS C:\Users\daichi\Documents\powershell\20211204>
$PSStyle.Background¤Î¥á¥ó¥Ð¡¼¤òɽ¼¨
PS C:\Users\daichi\Documents\powershell\20211204> $PSStyle.Background | Get-Member
TypeName: System.Management.Automation.PSStyle+BackgroundColor
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
FromRgb Method string FromRgb(byte red, byte green, byte blue), string FromRgb(int rgb)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Black Property string Black {get;}
Blue Property string Blue {get;}
BrightBlack Property string BrightBlack {get;}
BrightBlue Property string BrightBlue {get;}
BrightCyan Property string BrightCyan {get;}
BrightGreen Property string BrightGreen {get;}
BrightMagenta Property string BrightMagenta {get;}
BrightRed Property string BrightRed {get;}
BrightWhite Property string BrightWhite {get;}
BrightYellow Property string BrightYellow {get;}
Cyan Property string Cyan {get;}
Green Property string Green {get;}
Magenta Property string Magenta {get;}
Red Property string Red {get;}
White Property string White {get;}
Yellow Property string Yellow {get;}
PS C:\Users\daichi\Documents\powershell\20211204>
¤³¤ì¤òÀ°Íý¤¹¤ë¤È¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£
FromRgb¥á¥½¥Ã¥É¤ò»È¤¨¤Ð¤«¤Ê¤êºÙ¤«¤¯¿§¤ò»ØÄꤹ¤ë¤³¤È¤â¤Ç¤¤ë¤¬¡¢ºÇ½é¤ÏÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¡ÖRed¡×¤ä¡ÖBlue¡×¡¢¡ÖGreen¡×¤È¤¤¤Ã¤¿¥Ç¥Õ¥©¥ë¥È¤Î¿§¤Ç½½Ê¬¤À¤í¤¦¡£
¡û»È¤Ã¤Æ¤ß¤è¤¦
¤Ç¤ÏÁᮡ¢»È¤Ã¤Æ¤ß¤è¤¦¡£»È¤¤Êý¤Ï´Êñ¤À¡£PSAnsiRenderingFileInfo¤ò͸ú²½¤·¤¿¾õÂ֤ǡ¢¿§¤òÀßÄꤹ¤ì¤Ð¤è¤¤¡£¥Ç¥£¥ì¥¯¥È¥ê¤ÎÁ°·Ê¿§¤òÀ֤ˤ¹¤ë¤Î¤Ç¤¢¤ì¤Ð¡¢¼¡¤Î¤è¤¦¤ËÀßÄꤹ¤ë¡£
$PSStyle.FileInfo.Directory = $PSStyle.Foreground.Red
¼Â¹Ô¤¹¤ë¤È¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£¥Ç¥£¥ì¥¯¥È¥ê¤¬ÀÖ¤Çɽ¼¨¤µ¤ì¤Æ¤¤¤ë¤³¤È¤ò³Îǧ¤Ç¤¤ë¤È»×¤¦¡£
Á°·Ê¿§¤ÈÇØ·Ê¿§¤òƱ»þ¤Ë»ØÄꤹ¤ë¾ì¹ç¤Ï¼¡¤Î¤è¤¦¤Ë¤¹¤ë¡£
$PSStyle.FileInfo.Directory = $PSStyle.Foreground.White + $PSStyle.Background.Blue
¥«¥é¡¼É½¼¨¤Ï»ëǧÀ¤ò¹â¤á¤ë¾å¤ÇÌò¤ËΩ¤Ä¡£ÀßÄê¤òÊѹ¹¤·¤Æ¡¢ÉáÃʻȤäƤ¤¤ëLinux¤Î¥·¥§¥ë¤äls¥³¥Þ¥ó¥É¤Î¿§ÀßÄê¤ÈPowerShell¤Î¿§ÀßÄê¤ò¤½¤í¤¨¤Æ¤ª¤¯¤È¡¢°ãÏ´¶¤Ê¤¯»È¤¦¤³¤È¤¬¤Ç¤¤ë¤Ï¤º¤À¡£
¤Þ¤À¼Â¸³Ãʳ¬¤Ç¤Ï¤¢¤ë¤¬¡¢ÊØÍø¤Êµ¡Ç½¤Ç¤¢¤ê¡¢¥Ç¥Õ¥©¥ë¥ÈºÎÍѤòÁ˳²¤¹¤ëÂ礤ÊÍ×°ø¤¬¤¢¤ë¤È¤â»×¤¨¤Ê¤¤¤Î¤Ç¡¢¤¤¤º¤ì¥Ç¥Õ¥©¥ë¥È¤Îµ¡Ç½¤È¤·¤Æ»È¤¨¤ë¤è¤¦¤Ë¤Ê¤ë¤Î¤Ç¤Ï¤Ê¤¤¤À¤í¤¦¤«¡£
¡û»²¹Í
What's New in PowerShell 7.2 - PowerShell | Microsoft Docs
Using Experimental Features in PowerShell - PowerShell | Microsoft Docs