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でコマンド実行結果をテキストファイルに保存する

以下のようにパイプでOut-Fileコマンドレットに結果を渡すか、>演算子を用いて出力先のファイルを指定します。 PS C:\Users\santerabyte> Get-ChildItem | …

no image

PowerShellでテキストファイルに書き込む

こんにちは、今日はPowerShellでテキストファイルに書き込む方法についてまとめていきます。 確認環境 PSVersion 5.1.18362.1110 テキストファイルに書き込む System. …

no image

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

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

no image

PowerShellでトースト通知を送る

確認環境 PSVersion 5.1.18362.1110 トースト通知を送る [Windows.UI.Notifications.ToastNotificationManager, Win …

no image

現在実行中のタスク一覧をtasklistで取得する

確認環境 PowerShell 5.1 使い方 tasklist リンク tasklist | Microsoft Docshttps://docs.microsoft.com/ja-jp/windo …