locked
copying files using powershell RRS feed

  • Question

  • I'm trying to using powershell in deploying my vb project to my Test server. That is from my development machine to C:\inetpub\wwwroot\Project Folder on the server. 
    I have this so far, but it is not working.
        #$dest = $(get-item 'iis:\sites\default web site\Test').physicalPath
        $dest = "http://Test Server/IPABS"
        $build = Get-ChildItem $args[0]
        $content = $null
        Remove-Item $dest  -recurse -force
        foreach($file in $build){
    Copy-Item $file.FullName $dest -Force -recurse
       }
    can someone tell me what I'm doing wrong?
    thanks.
    Wednesday, September 21, 2011 6:31 PM

Answers

  • Hi,

    What that message is telling you: You cannot copy files to an "http:" destination.

    Bill

    • Proposed as answer by Bill_Stewart Monday, September 26, 2011 9:24 PM
    • Marked as answer by BSonPosh Thursday, October 6, 2011 1:29 PM
    Wednesday, September 21, 2011 9:09 PM

All replies

  • Hi,

    1) When you say something didn't work, you have to say how it didn't work.

    2) Look at your $dest variable. Is it a valid destination path?

    Bill

    Wednesday, September 21, 2011 6:34 PM
  • thanks for your response.
    $dest variable is valid. when I run the script I get this error:
    Remove-Item : Cannot find drive. A drive with the name 'http' does not exist.
    At C:\TestDeploy.ps1:6 char:12
    + Remove-Item <<<<  $dest  -recurse -force
        + CategoryInfo          : ObjectNotFound: (http:String) [Remove-Item], DriveNotFoundException
        + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
    Wednesday, September 21, 2011 7:24 PM
  • Hi,

    What that message is telling you: You cannot copy files to an "http:" destination.

    Bill

    • Proposed as answer by Bill_Stewart Monday, September 26, 2011 9:24 PM
    • Marked as answer by BSonPosh Thursday, October 6, 2011 1:29 PM
    Wednesday, September 21, 2011 9:09 PM
  • You can copy to a unc share or a mapped drive. To copy to a url I would expect to need to use ftp, or similar.

     


    Richard Mueller - MVP Directory Services
    Wednesday, September 21, 2011 9:12 PM
  • I'm trying to using powershell in deploying my vb project to my Test server. That is from my development machine to C:\inetpub\wwwroot\Project Folder on the server. 
    I have this so far, but it is not working.
        #$dest = $(get-item 'iis:\sites\default web site\Test').physicalPath
        $dest = "http://Test Server/IPABS"
        $build = Get-ChildItem $args[0]
        $content = $null
        Remove-Item $dest  -recurse -force
        foreach($file in $build){
     Copy-Item $file.FullName $dest -Force -recurse
       }
    can someone tell me what I'm doing wrong?
    thanks.


    The best an most effective way to deploy a web is with XCOPY.  It is called XCOPY deployment,

    Locally we use Visual Studio as it can deploy to a file system, via FTP and by WebDAV / Frontpage.  Frontpage extensions are not available for IIS 7.x but can be purchased from a third party.

     


    jv
    Wednesday, September 21, 2011 9:15 PM
  • Would something similar to this do the trick (presuming FTP connection is possible).

     

    goto part2
    open server
    username
    password
    put file.txt
    get file.txt
    quit
    :part2
    cd C:\someproject
    ftp -s:%0


    Thursday, September 22, 2011 4:30 AM