【问题标题】:The term 'xsd' is not recognized as the name of a cmdlet, function, script file, or operable program术语“xsd”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称
【发布时间】:2014-11-01 19:30:14
【问题描述】:

执行以下脚本时(这是实际脚本的一部分),我在 powershell 中收到以下错误消息:

The term 'xsd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:10 char:3

$xsds = ls *.xsd | %{ $_.Name }

if ($xsds.Count -eq 0) { exit }

# Add '.\' to last file name, see http://stackoverflow.com/questions/906093/xsd-exe-output-filename
$last = $xsds | select -last 1
$last = '.\' + $last
$xsds[$xsds.Count - 1] = $last

& xsd $xsds /c /n:OutputFolder

是否需要安装 Powershell 才能首先运行“xsd”cmdlet?

$env:Path的输出:

PS C:\Users\Administrator\Desktop\New> $env:Path
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Mi
crosoft\Web Platform Installer\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files
(x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Micro
soft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program F
iles (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\
PS C:\Users\Administrator\Desktop\New>

文件夹中有一个xsd.exe

C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools

C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64

【问题讨论】:

  • XSD 是系统中某处的 exe 文件吗?您可以检查$env:Path 以查看该路径是否存在。 XSD 不是我熟悉的 powershell cmdlet。
  • @Matt 我已将请求的信息添加到帖子中。
  • xsd 不是 cmdlet。就像错误消息告诉你的一样。尝试相信错误信息。

标签: powershell xsd powershell-cmdlet


【解决方案1】:

您列出的路径不是 PATH 环境变量的一部分。因此,您有两个选择。将目录添加到路径或仅通过完整路径引用 exe。

& "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\xsd.exe" $xsds /c /n:OutputFolder

如果你想改变你的路径,你可以像这样更新它们

$env:Path += ";C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools"

如果您需要 x64 路径,只需更新字符串即可。

【讨论】:

    猜你喜欢
    • 2021-11-01
    • 2021-05-23
    • 2020-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多