diff --git a/provisioner/powershell/provisioner.go b/provisioner/powershell/provisioner.go index 82ec98c82..6eb9c5572 100644 --- a/provisioner/powershell/provisioner.go +++ b/provisioner/powershell/provisioner.go @@ -269,6 +269,8 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error { ui.Error(fmt.Sprintf("Unable to extract inline scripts into a file: %s", err)) } scripts = append(scripts, temp) + // Remove temp script containing the inline commands when done + defer os.Remove(temp) } for _, path := range scripts { diff --git a/provisioner/windows-shell/provisioner.go b/provisioner/windows-shell/provisioner.go index babc9b5ec..f9b105121 100644 --- a/provisioner/windows-shell/provisioner.go +++ b/provisioner/windows-shell/provisioner.go @@ -190,6 +190,8 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error { ui.Error(fmt.Sprintf("Unable to extract inline scripts into a file: %s", err)) } scripts = append(scripts, temp) + // Remove temp script containing the inline commands when done + defer os.Remove(temp) } for _, path := range scripts {