首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Powershell扩展PSCX远程压缩文件

使用Powershell扩展PSCX远程压缩文件
EN

Stack Overflow用户
提问于 2013-04-25 15:48:14
回答 1查看 643关注 0票数 0

基本上我想这样做:

代码语言:javascript
复制
foreach ($SERVER_NAME in $SERVER_NAME_LIST)
{

$SESSION = New-PSSession -ComputerName $SERVER_NAME -Credential $CRED
Invoke-Command -Session $SESSION -ScriptBlock 
{   
    Write-Zip -Path $PATH -OutputPath test.zip -IncludeEmptyDirectories
}
}

我得到了这个错误:

代码语言:javascript
复制
The term 'Write-Zip' 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.

我真的需要在每个远程机器上安装这个扩展并每次都调用import module吗?

提前感谢您的帮助

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-25 15:52:23

是的,您需要在每台远程机器上安装,因为invoke-command将在远程机器上运行命令。如果您使用的是Powershell v3,则不需要手动导入,因为PSV3可以自动导入模块,但是如果您使用的是powershell-v2,则需要在-scriptblock {ipmo path\to\module}中导入。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16209132

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档