首页 > 解决方案 > 创建自动化 - powershell

问题描述

我正在尝试在场景如下的情况下进行自动化:我有一个包含所有数字的文本文件 ABC.txt:

ABC.txt:

12234

12345

123455

通过 PowerShell 脚本,我希望将输出保存在一个文本文件中,例如:

Sunny day

Rainy Day

Windy day

This is 12234

This is 12345

This is 123455

所以我执行了以下脚本:

$File1 = @((Get-Content "E:\ABC.txt"))
For($a = 0;$a -lt $File1.count;$a++){-join ("This is ", $File1[$a]) | Out-File -FilePath "E:\XYZ.txt" -Append}

上面的脚本在 XYZ.txt 文件中显示输出:-

This is 12234

This is 12345

This is 123455

能否请您告诉我如何在上述输出之上添加以下内容:

Sunny day

Rainy Day

Windy day

标签: powershell-4.0

解决方案


推荐阅读