powershell上传问题


PowerShell交流中心分类: Powershell基础powershell上传问题
-1
robo asked 7 年 ago

$appdirectory=”D:\shell”
$username=”test”
$password=”test”
$url=”ftp://192.168.20.17″
 
Set-Location$appdirectory
$webclient=New-Object-TypeName System.Net.WebClient
$webclient.Credentials=New-Object System.Net.NetworkCredential($username,$password)
$files=Get-ChildItem-Path $appdirectory-Recurse |Where-Object{!($_.PSIsContainer)}
foreach($filein$files)
{
$relativepath=(Resolve-Path-Path $file.FullName-Relative).Replace(“.\”,””).Replace(‘\’,’/’)
$uri=New-Object System.Uri(“$url/$relativepath”)
“Uploading to “+$uri.AbsoluteUri
$webclient.UploadFile($uri,$file.FullName)
}
$webclient.Dispose()
 
我在通过上面的方法上传文件的时候,在D:\shell\module\test.txt ,无法上传,
 
提示ftp服务器上,没有module这个目录。这个为什么不会再ftp服务器上自动创建module这个文件夹呢。谢谢
 
 

1 Answers