相変わらず PowerShell Wiki の方でAdd-Contentコマンドレットについてまとめています。
次のコマンドレットに取りかかれるのはいつになることやら.....
指定したファイルに追記する値を指定します。追記できる値は、文字列、コマンドレットが返す値などを指定します。
このコマンドレットを実行すると、既存のTest.txtファイルに「テストファイルです」という文字列を追記します。
このコマンドレットを実行すると変数 $a に代入した文字列を Test.txt へ追記します。
このコマンドレットを実行すると Get-Dateコマンドレットが返す値を Date.txt に追記します。このようにコマンドレットが返す値を追記することが可能ですが、複数の値を一度に返すようなコマンドレットを指定した場合には期待通りの値を取得できないので注意が必要です。
このコマンドレットを実行すると、Sample.txt の内容を Test.txt に追記します。-value パラメータに直接パスを指定しても、パスを文字列として認識してしまうためこのような処理が必要となります。
このコマンドレットは Get-Service のコマンドレットの結果を ServiceList.txtに追記しようとしていますが期待通りの結果にはなりません。("System.ServiceProcess.ServiceController"という文字列がサービスの数だけ書き込まれます)これは、Get-Service が複数のオブジェクトを返すためです。
などの工夫が必要です。
Theme design by Jelle Druyts
Pick a theme: BlogXP business calmBlue Candid Blue dasBlog dasblogger DirectionalRedux Discreet Blog Blue Elegante essence Just Html MadsSimple Mobile Mono Movable Radio Blue Movable Radio Heat nautica022 orangeCream Portal Project84 Project84Grass Slate Sound Waves Tricoleur useit.com Voidclass2 BlogXP business calmBlue Candid Blue dasBlog dasblogger DirectionalRedux Discreet Blog Blue Elegante essence Just Html MadsSimple Mobile Mono Movable Radio Blue Movable Radio Heat nautica022 orangeCream Portal Project84 Project84Grass Slate Sound Waves Tricoleur useit.com Voidclass2
Powered by: newtelligence dasBlog 2.0.7226.0
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2009, HIRO
E-mail