powershell - 用于将文件从一台服务器复制到另一台服务器的 Powershell 脚本
问题描述
带有凭据的 PowerShell 脚本,用于将文件从一台服务器复制到另一台服务器。
我已经编写了代码,但它不工作。我的代码有什么问题?我得到错误
New-PSSession : myComp1 连接到远程服务器 myComp1 失败并显示以下错误消息:WS-Management 服务无法处理请求。在 myComp1 计算机上的 WSMan: 驱动器中找不到 Microsoft.PowerShell 会话配置。有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。
$pw = ConvertTo-SecureString -AsPlainText -Force -String password
$creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "domain\UserName", $pw
$trgtSession = New-PSSession -ComputerName myComp1 -Credential $creds
Copy-Item -ToSession $trgtSession -Path "C:\Users\" -Destination "C:\Users\desktop\" -Recurse
预期结果:使用凭据将文件从一台服务器移动到另一台服务器的代码。
解决方案
推荐阅读
- angular - 插件 Base64 不适用于 ionic 3
- angular - 无法读取角度 4 中未定义值的属性
- dns - 服务名称在主节点而不是其他节点上解析
- android - Google Play Console - 翻译服务:我可以在 xml 文件中描述我的字符串吗?
- python - 完成测试后,用分类模型预测重新填充数据框的替代方法?
- android - 对于 Android,我如何从 SQLite 中的日期和日期范围获取数据,其中 Android 变量可以传递给查询?
- java - 请放心接收 null 的实际值,但邮递员显示值存在
- google-chrome - VS2017 15.7.1版禁用F5调试new-Chrome-window
- d3.js - D3双击重置粘性节点
- java - Hibernate @ManyToMany 不使用 joinTable 并产生笛卡尔而不是内部连接