diff --git a/communicator/winrm/communicator.go b/communicator/winrm/communicator.go index 6cf2bce37..bab2ebde2 100644 --- a/communicator/winrm/communicator.go +++ b/communicator/winrm/communicator.go @@ -122,26 +122,11 @@ func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packer.RemoteCmd) { } // Upload implementation of communicator.Communicator interface -func (c *Communicator) Upload(path string, input io.Reader, fi *os.FileInfo) error { +func (c *Communicator) Upload(path string, input io.Reader, _ *os.FileInfo) error { wcp, err := c.newCopyClient() - if err != nil { - return err - } - if err != nil { return fmt.Errorf("Was unable to create winrm client: %s", err) } - client, err := c.newWinRMClient() - stdout, _, _, err := client.RunWithString(fmt.Sprintf("powershell -Command \"(Get-Item %s) -is [System.IO.DirectoryInfo]\"", path), "") - if err != nil { - return fmt.Errorf("Couldn't determine whether destination was a folder or file: %s", err) - } - if strings.Contains(stdout, "True") { - // The path exists and is a directory. - // Upload file into the directory instead of overwriting. - path = filepath.Join(path, filepath.Base((*fi).Name())) - } - log.Printf("Uploading file to '%s'", path) return wcp.Write(path, input) }