
PowerShellで
・テキストファイルを作成
できます!
コード
ここでは例として
・デスクトップ配下にファイル「aiueo.txt」を新規作成して
・文字列「hogehoge」と書き込み
をします。
# 作成するファイルパスを指定
$filePath = "C:\Users\user\Desktop\aiueo.txt"
$ws = New-Object -ComObject Wscript.Shell
try
{
# 書き込み
Add-Content -Path $filePath -Value "hogehoge" -Encoding Default -ErrorAction Stop
$ws.popup("テキストファイルを作成しました。")
}
catch
{
$ws.popup("エラー : " + $PSItem)
}
実行結果
テキストファイルを作成できました。



参考
上記のコードで使用した以下の詳細は、公式サイトをご確認ください。
●「Add-Content」コマンドレット