1
我已经写了下面的脚本PS使用到7zip的文件夹7Zip4Powershell然而,当它失败,出现以下错误在生成过程中:TFS PowerShell的安装,模块没有发现
Install-Module : The term 'Install-Module' 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 C:\Build\Work\19\s\DevOps\7zCompress.ps1:3 char:5
+ Install-Module -Scope CurrentUser -Name 7Zip4PowerShell -Verbose -Force
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Compress-7Zip : The term 'Compress-7Zip' 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 C:\Build\Work\19\s\DevOps\7zCompress.ps1:18 char:1
+ Compress-7Zip -Path $sourcedir -ArchiveFileName $filename -CompressionLevel $com ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Compress-7Zip:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Process completed with exit code 0 and had 1 error(s) written to the error stream.
脚本
param([string]$sourcedir, [string]$filename, [string]$compressionLevel, [string]$compressionMethod)
If (-not (Get-Module -ListAvailable -Name 7Zip4PowerShell)) {
Install-Module -Scope CurrentUser -Name 7Zip4PowerShell -Verbose -Force
}
If(Test-Path $filename) {
Remove-Item $filename
}
If (-not $compressionLevel) {
$compressionLevel = "Normal"
}
If (-not $compressionMethod) {
$compressionMethod = "Lzma2"
}
Compress-7Zip -Path $sourcedir -ArchiveFileName $filename -CompressionLevel $compressionLevel -CompressionMethod $compressionMethod
如何获得TFS 2015本地认识安装模块是一个有效的命令?我已经在该机器上安装了MSI for Install-Module。我是否需要将其添加为构建代理的能力?
将'Install-Module'更改为'Import-Module'? – gms0ulman
与上面的@ gms0ulman是啊,没有安装模块,你想要将它导入到会话中。 – Paolis
有一个'install-module'(如果你安装了软件包管理),但是'get-module'显示这个模块已经在本地可用,所以他应该导入它。 –