powershell - 仅从文件的完整路径中获取文件名

标签 powershell

我想拆分路径并将文件名 test.xls 保存在一个新变量中

$namearray = "C:\Users\z003m\Desktop\Service_Tickets\automationscript\vbs\Newfolder\test.xls"

最佳答案

推荐使用内置的 Split-Path :

$newVariable = Split-Path $namearray -Leaf

关于powershell - 仅从文件的完整路径中获取文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44369465/

相关文章:

powershell - Powershell启 Action 业脚本 block 中的Powershell V3变量未扩展

PowerShell,具有 -Depth 输出的 Get-ChildItem

powershell - TeamCity 不使用 powershell 显示服务消息

powershell - Powershell-数字格式显示错误的结果

powershell - 检查 HTTP 端口是否在 Windows 上打开

windows - 自动安装 IIS

sql-server - 确定给定命名空间是否存在 wmiobject 类

powershell - 驱动器号 + 驱动器物理类型 (Powershell)

sql-server - 使用 Restore-SqlDatabase cmdlet 时无法绑定(bind) RelocateFile

powershell - powershell 中的脚本无法使用数组变量