2014-11-01 81 views
0

當執行以下腳本(這是實際腳本的一部分)時,出現以下錯誤消息在PowerShell中:術語'xsd'不被識別爲cmdlet,函數,腳本文件或可操作程序的名稱

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

+0

XSD是否是您的系統上某個exe文件?您可以檢查'$ env:Path'來查看該路徑是否存在。 XSD不是我熟悉的powershell cmdlet。 – Matt 2014-11-01 19:45:45

+0

@Matt我在帖子中添加了請求的信息。 – SeToY 2014-11-01 19:51:31

+0

'xsd'不是一個cmdlet。就像錯誤信息告訴你的一樣。嘗試相信錯誤信息。 – 2014-11-01 19:55:43

回答

2

您列出的路徑是不是你的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" 

更新它們如果您需要64位路徑剛剛更新的字符串。

相關問題