3テラバイト

プログラム関連備忘録サイト。主にゲーム。

PowerShell

PowerShellで指定オブジェクトを次のコマンドに送信するコマンドレットWrite-Outputの使い方

投稿日:

こんにちは、今日は指定オブジェクトをパイプラインの次のコマンドに送信するコマンドレットWrite-Outputの使い方についてまとめていきます。

このコマンドがパイプラインの最後のコマンドである場合は、オブジェクトがコンソールに出力されます。

確認環境

PSVersion 5.1.18362.1110

Write-Outputの使い方

文字列を渡し、その後にパイプをつなげない場合はそのままその文字列がコンソールに出力されます。

Write-Output "test"

以下のようにGet-Memberコマンドレットにパイプラインで出力を渡すと、文字列オブジェクトSystem.Stringのメンバー情報が出力されます。

PS C:\Users\santerabyte> Write-Output "test" | 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.CompareTo(System.Object obj), int IComparable[string].CompareTo(string other)
Contains         Method                bool Contains(string value)
...

リンク

Write-Output (Microsoft.PowerShell.Utility) – PowerShell | Microsoft Docs
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/write-output?view=powershell-7.1

-PowerShell


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です


reCaptcha の認証期間が終了しました。ページを再読み込みしてください。

関連記事

no image

PowerShellで特定ディレクトリのファイル内文字列を置換する

Get-ChildItem . | ForEach-Object {Get-Content -Encoding utf8 $_ | ForEach-Object {$_ -creplace &#039 …

no image

PowerShellでプロセスを停止するコマンドレットStop-Processの使い方

こんにちは、今日はPowerShellでプロセスを停止するコマンドレットStop-Processの使い方についてまとめていきます。 確認環境 PSVersion 5.1.18362.1110 Stop …

no image

PowerShellでCSVファイルを読み込む

こんにちは、今日はPowerShellでCSVファイルを読み込む方法についてまとめていきます。 確認環境 PSVersion 5.1.18362.1110 CSVファイルを読み込む CSVファイルを出 …

no image

UnityでPowerShellの実行結果を取得する

以下の例ではGet-ChildItemコマンドレットを引数なしで実行、標準出力への出力をDebug.LogでUnityコンソールに出力しています。 System.Diagnostics.Process …

no image

PowerShellでWindows Management Instrumentation (WMI)オブジェクトを取得するコマンドレットGet-WmiObjectの使い方

こんにちは、今日はPowerShellでWindows Management Instrumentation (WMI)オブジェクトを取得するコマンドレットGet-WmiObjectの使い方についてま …