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でCSVファイルを読み込む

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

no image

PowerShellでアイテムのプロパティを取得するコマンドレットGet-ItemPropertyの使い方

こんにちは、今日はPowerShellでアイテムのプロパティを取得するコマンドレットGet-ItemPropertyの使い方についてまとめていきます。 確認環境 PSVersion 5.1.18362 …

no image

Windows10のタスクスケジューラでPowerShellスクリプト実行時にウィンドウを表示しないようにする

こんにちは、今日はタスクスケジューラでPowerShellスクリプト実行時にウィンドウを表示しないようにする方法についてまとめていきます。 確認環境 タスク スケジューラ バージョン: 1.0 JSc …

no image

PowerShellの比較演算子一覧

確認環境 PSVersion 5.1.18362.1110 比較演算子 演算子他言語の演算子説明-eq==等しい(equal)-ne!=等しくない(not equal)-gt>より大きい(Greate …

no image

PowerShellでロード済のアセンブリ一覧を取得する

以下のように現在のアプリケーション ドメインを取得し、そのドメインで読み込まれているアセンブリをGetAssemblies関数で取得します。 PS C:\Users\santerabyte> & …