gpt4 book ai didi

powershell - 如何在PowerShell中获取字符串而不是数组?

转载 作者:行者123 更新时间:2023-12-02 22:14:47 25 4
gpt4 key购买 nike

我正在尝试执行以下操作:

$files = Get-ChildItem c:\temp | Select-Object Name
foreach ($i in $files) {
Write-Host "Filename is $i"
}

示例结果:
Filename is @{Name=oracle10204.rsp}
Filename is @{Name=powershell.txt}

我如何只获得以下内容?
Filename is oracle10204.rsp
Filename is powershell.txt

最佳答案

使用 -Name 开关,您只能获取对象名称:

 Get-ChildItem c:\temp -Name

关于powershell - 如何在PowerShell中获取字符串而不是数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7610521/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com