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でテキストファイルに書き込む

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

no image

PowerShellでアイテムをコピーするコマンドレットCopy-Itemの使い方

こんにちは、今日はPowerShellでアイテムをコピーするコマンドレットCopy-Itemの使い方についてまとめていきます。 確認環境 PSVersion 5.1.18362.1110 パラメータ …

no image

PowerShellで別ウィンドウにテーブル出力するコマンドレットOut-GridViewの使い方

こんにちは、今日はPowerShellで別ウィンドウにテーブル出力するコマンドレットOut-GridViewの使い方についてまとめていきます。 確認環境 PSVersion 5.1.18362.111 …

no image

PowerShellの論理演算子一覧

確認環境 PSVersion 5.1.18362.1110 演算子他言語の演算子説明-not!否定!!否定-and&論理積-or|論理和-xor^排他的論理和 リンク if ステートメントにつ …

no image

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

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