PowerShell ヨクワカランって感じだったので色々まとめた
macOS からも PowerShell が使える。物好きな方はどうぞ。というかこういうことできるのはやっぱり .NET Core にコードを寄せているからなのか?(これはいいこと)。
brew cask install powersh $ pwsh PowerShell v6.0.2 Copyright (c) Microsoft Corporation. All rights reserved. https://aka.ms/pscore6-docs Type 'help' to get help. PS /Users/maintainer> Get-Host Name : ConsoleHost Version : 6.0.2 ... DebuggerEnabled : True IsRunspacePushed : False Runspace : System.Management.Automation.Runspaces.LocalRunspace
Although this repo started as a fork of the Windows PowerShell code base, changes made in this repo do not make their way back to Windows PowerShell 5.1 automatically. This also means that issues tracked here are only for PowerShell Core 6.0. Windows PowerShell specific issues should be opened on UserVoice. (Windows PowerShell vs PowerShell Core)
6.0 以降を PowerShell Core とよんでいる模様
gm
or Get-Member
でメンバ一覧を表示できる
PS /Users/maintainer> $error | gm TypeName: System.Management.Automation.ErrorRecord Name MemberType Definition ---- ---------- ---------- Equals Method bool Equals(System.Object obj) GetHashCode Method int GetHashCode() ... GetObjectData Method void GetObjectData(System.Runtime.Serialization.SerializationInfo info, PSMessageDetails ScriptProperty System.Object PSMessageDetails {get=& { Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails };}
json にして吐き出す
PS /Users/maintainer> $error | ConvertTo-Json [ { "Exception": { "ErrorRecord": "The term 'Convert-ToJson' is not recognized as the name of a cmdlet, function, script file, or operable program.\nCheck the spelling of the name, or if a path was included, verify that the path is correct and try again.", ... "PipelineIterationInfo": [], "PSMessageDetails": null } ]
便利な変数: about_Preference_Variables