- PowerShell 教程
- PowerShell - 主页
- PowerShell - 概述
- PowerShell - 环境设置
- PowerShell - Cmdlet
- PowerShell - 文件和文件夹
- PowerShell - 日期和计时器
- PowerShell - 文件 I/O
- PowerShell - 高级 Cmdlet
- PowerShell - 脚本编制
- PowerShell - 特殊变量
- PowerShell - 运算符
- PowerShell - 循环
- PowerShell - 条件
- PowerShell - 数组
- PowerShell - 哈希表
- PowerShell - 正则表达式
- PowerShell - 反引号
- PowerShell - 括号
- PowerShell - 别名
- PowerShell 有用资源
- PowerShell - 快速指南
- PowerShell - 有用资源
- PowerShell - 讨论
Powershell - 创建 XML 文件
Cmdlet
New-Item Cmdlet 用于创建 xml 文件和 Set-Content Cmdlet 用于将内容放入其中。
步骤 1
在此示例中,我们创建一个名为 test.xml 的 xml 文件
在 PowerShell ISE 控制台中键入以下命令
New-Item D:\temp\test\test.xml -ItemType File
您可以看到在 D:\temp\test 目录中创建的 test.xml。
步骤 2
在此示例中,我们将内容添加到 test.xml 中。
在 PowerShell ISE 控制台中键入以下命令
Set-Content D:\temp\test\test.xml '<title>Welcome to TutorialsPoint</title>'
步骤 3
在此示例中,我们读取 test.xml 的内容。
Get-Content D:\temp\test\test.xml
输出
您可以在 PowerShell 控制台中看到以下输出。
<title>Welcome to TutorialsPoint</title>
powershell_files_io.htm
广告