术语 'xsd' 不被识别为 cmdlet、函数、脚本文件或可操作程序的名称



执行以下脚本(这是实际脚本的一部分)时,我在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:UsersAdministratorDesktopNew> $env:Path
C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program FilesMi
crosoftWeb Platform Installer;C:Program FilesMicrosoft SQL ServerClient SDKODBC110ToolsBinn;C:Program Files
(x86)Microsoft SQL Server120ToolsBinn;C:Program FilesMicrosoft SQL Server120ToolsBinn;C:Program FilesMicro
soft SQL Server120DTSBinn;C:Program Files (x86)Microsoft SQL Server120ToolsBinnManagementStudio;C:Program F
iles (x86)Microsoft SQL Server120DTSBinn;C:Program Files (x86)Windows Kits8.1Windows Performance Toolkit
PS C:UsersAdministratorDesktopNew>

文件夹中有一个xsd.exe可用:

C:Program Files (x86)Microsoft SDKsWindowsv8.1AbinNETFX 4.5.1 Tools

C:Program Files (x86)Microsoft SDKsWindowsv8.1AbinNETFX 4.5.1 Toolsx64

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

& "C:Program Files (x86)Microsoft SDKsWindowsv8.1AbinNETFX 4.5.1 Toolsxsd.exe" $xsds /c /n:OutputFolder

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

$env:Path += ";C:Program Files (x86)Microsoft SDKsWindowsv8.1AbinNETFX 4.5.1 Tools"

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

相关内容

最新更新