Powershell Invoke-Command Remove-Item 远程服务器 [英] Powershell Invoke-Command Remove-Item Remote Server
本文介绍了Powershell Invoke-Command Remove-Item 远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除远程服务器特定文件夹中的文件.我在 Powershell 中执行以下操作:
I want to delete files on a particular folder of a remote server. I execute the following in Powershell:
Invoke-Command -Computer 'compname1' -ScriptBlock {Remove-Item -$args -force } -ArgumentList 'c:\BizTalkDeployment'
我收到以下错误:
Cannot find drive. A drive with the name '-c' does not exist.
c:\BizTalkDeployment 是服务器 compname1 上的正确路径.
c:\BizTalkDeployment is the correct path on server compname1.
谁能解释一下我做错了什么?
Can anyone please explain what I've done wrong?
推荐答案
删除 $args 前面的 - 并重新运行脚本.您甚至可以尝试将脚本块更改为:
Remove the - in front of $args and re-run the script. You might even try changing the script block to:
Remove-Item -Path $args[0]
这篇关于Powershell Invoke-Command Remove-Item 远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文