Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke-FromTask: Unable to run scheduled task (no message) #12

Closed
mwrock opened this issue Sep 16, 2014 · 7 comments
Closed

Invoke-FromTask: Unable to run scheduled task (no message) #12

mwrock opened this issue Sep 16, 2014 · 7 comments

Comments

@mwrock
Copy link
Member

mwrock commented Sep 16, 2014

Migrated from https://boxstarter.codeplex.com/workitem/69

I'm trying to use the Invoke-FromTask command in the Boxstarter.Common with no success. Suggestions?

Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:\Users\vagrant> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1
PS C:\Users\vagrant> boxstarter

Boxstarter: Installing Chocolatey
Boxstarter Version 2.4.15
(c) 2014 Matt Wrock. http://boxstarter.org

Boxstarter: Disabling Automatic Updates from Windows Update
True
Boxstarter: Enabling Automatic Updates from Windows Update
PS C:\Users\vagrant> boxstartershell

C:\Users\vagrant>powershell.exe -ExecutionPolicy bypass -NoExit -Command "&'C:\Users\vagrant\AppData\Roaming\Boxstarter\BoxstarterShell.ps1'"

Welcome to the Boxstarter shell!
The Boxstarter commands have been imported from C:\Users\vagrant\AppData\Roaming\Boxstarter and are available for you to run in this shell.
You may also import them into the shell of your choice.

Here are some commands to get you started:
Install a Package:   Install-BoxstarterPackage
Create a Package:    New-BoxstarterPackage
Build a Package:     Invoke-BoxstarterBuild
Enable a VM:         Enable-BoxstarterVM
For Command help:    Get-Help <Command Name> -Full

For Boxstarter documentation, source code, to report bugs or participate in discussions, please visit http://boxstarter.org

PS C:\> Import-Module Boxstarter.Common

WARNING: The names of some imported commands from the module 'Boxstarter.Common' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.

PS C:\> Invoke-FromTask "DISM /Online /Online /NoRestart /Enable-Feature /Telnet-Client" -IdleTimeout 20

ERROR: The system cannot find the file specified.
Unable to run scheduled task. Message from task was
At C:\Users\vagrant\AppData\Roaming\Boxstarter\Boxstarter.Common\Invoke-FromTask.ps1:108 char:9
+         throw "Unable to run scheduled task. Message from task was $taskResult"
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Unable to run s... from task was :String) [], RuntimeException
    + FullyQualifiedErrorId : Unable to run scheduled task. Message from task was
@dragon788
Copy link
Contributor

I'm getting this same error when attempting to port some of your packer-template scripts over to boxcutter/windows as a more PowerShell native option and may be replacing/aliasing Chocolatey as a "configuration management" option with Boxstarter since it pulls it in as well with its bootstrap.

    virtualbox-iso: Chocolatey installed 6/6 package(s). 0 package(s) failed.
    virtualbox-iso: See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
    virtualbox-iso: Boxstarter Module Installer completed
    virtualbox-iso: [WIN-P6VM7D4HU1T]Boxstarter: Installing package a:\package.ps1
    virtualbox-iso: [WIN-P6VM7D4HU1T]Boxstarter: Disabling Automatic Updates from Windows Update
    virtualbox-iso: Attempting to build package from 'temp_BoxstarterPackage.nuspec'.
    virtualbox-iso: Successfully created package 'temp_BoxstarterPackage.1.0.0.nupkg'
    virtualbox-iso: [WIN-P6VM7D4HU1T]Boxstarter: Created a temporary package temp_BoxstarterPackage from a:\package.ps1 in C:\Users\vagrant\AppData\Roaming\boxstarter\BuildPackages
    virtualbox-iso: [WIN-P6VM7D4HU1T]++ Boxstarter starting Calling Chocolatey to install temp_BoxstarterPackage. This may take several minutes to complete...
    virtualbox-iso: Installing the following packages:
    virtualbox-iso: temp_BoxstarterPackage
    virtualbox-iso: By installing you accept licenses for the packages.
    virtualbox-iso:
    virtualbox-iso: temp_BoxstarterPackage v1.0.0 (forced)
    virtualbox-iso: [WIN-P6VM7D4HU1T]Boxstarter: Enabling Remote Desktop...
    virtualbox-iso: [WIN-P6VM7D4HU1T]Boxstarter: Enabling Remote Desktop NLA ...
    virtualbox-iso: Ok.
    virtualbox-iso: [WIN-P6VM7D4HU1T]Boxstarter: Setting PowerShell execution context to Unrestricted
    virtualbox-iso: [WIN-P6VM7D4HU1T]Boxstarter: Removing unused features...
    virtualbox-iso: Success Restart Needed Exit Code      Feature Result
    virtualbox-iso: ------- -------------- ---------      --------------
    virtualbox-iso: ERROR: The system cannot find the file specified.
    virtualbox-iso: Unable to run scheduled task. Message from task was
    virtualbox-iso: At C:\Users\vagrant\AppData\Roaming\boxstarter\Boxstarter.Common\Invoke-FromTas
    virtualbox-iso: k.ps1:136 char:9
    virtualbox-iso: True    No             Success        {Windows PowerShell ISE}
    virtualbox-iso: +         throw "Unable to run scheduled task. Message from task was
    virtualbox-iso: $taskResult"
    virtualbox-iso: +
    virtualbox-iso: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    virtualbox-iso: + CategoryInfo          : OperationStopped: (Unable to run s... from task
    virtualbox-iso: was :String) [], RuntimeException
    virtualbox-iso: + FullyQualifiedErrorId : Unable to run scheduled task. Message from task
    virtualbox-iso: was
    virtualbox-iso: The install of temp_boxstarterpackage was NOT successful.
    virtualbox-iso: Error while running 'C:\ProgramData\chocolatey\lib\temp_BoxstarterPackage\tools\ChocolateyInstall.ps1'.
    virtualbox-iso: See log for details.
    virtualbox-iso:
    virtualbox-iso: Failures:
    virtualbox-iso: - temp_boxstarterpackage
    virtualbox-iso: Chocolatey installed 0/1 package(s). 1 package(s) failed.
    virtualbox-iso: See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
    virtualbox-iso: [WIN-P6VM7D4HU1T]++ Boxstarter finished Calling Chocolatey to install temp_BoxstarterPackage. This may take several minutes to complete... 00:00:20.5890115
    virtualbox-iso: True
    virtualbox-iso: [WIN-P6VM7D4HU1T]Boxstarter: Restore Automatic Updates from Windows Update
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso: Errors       : {Chocolatey reported an unsuccessful exit code of 1. See
    virtualbox-iso: C:\Users\vagrant\AppData\Local\Boxstarter\boxstarter.log for
    virtualbox-iso: details.}
    virtualbox-iso: ComputerName : localhost
    virtualbox-iso: Completed    : True
    virtualbox-iso: FinishTime   : 6/16/2016 12:00:53 PM
    virtualbox-iso: StartTime    : 6/16/2016 12:00:29 PM
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso: Chocolatey : Chocolatey reported an unsuccessful exit code of 1. See
    virtualbox-iso: C:\Users\vagrant\AppData\Local\Boxstarter\boxstarter.log for details.
    virtualbox-iso: At C:\Users\vagrant\AppData\Roaming\boxstarter\boxstarter.chocolatey\Invoke-Cho
    virtualbox-iso: colateyBoxstarter.ps1:201 char:5
    virtualbox-iso: +     Chocolatey install $bootstrapPackage -source $source -force:$force
    virtualbox-iso: -executio ...
    virtualbox-iso: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    virtualbox-iso: ~~~
    virtualbox-iso: + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorExcep
    virtualbox-iso: tion
    virtualbox-iso: + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio
    virtualbox-iso: n,chocolatey
    virtualbox-iso:

@mwrock
Copy link
Member Author

mwrock commented Jun 17, 2016

you can probably work around this by calling Create-BoxstarterTask and passing the pscredentials that the script should run as before running boxstarter.

@dragon788
Copy link
Contributor

Hi @mwrock it appears that the script I'm borrowing from your packer-templates should already be doing that. https://github.com/mwrock/packer-templates/blob/master/scripts/boxstarter.ps1

@deluxebrain
Copy link

@dragon788 looks like Im following the same blogpost as yourself - and hitting the same issue... Did you manage to get this working?
Cheers

@deluxebrain
Copy link

deluxebrain commented Jun 25, 2016

@dragon788 Assuming we were sharing the same or similar issues (and looking at your error log I think we are...) I have got passed this issue using information from the following link.

Basically boiled down to an issue with running Boxstarter over a winrm session.

@dragon788
Copy link
Contributor

Good call, after examining how I was calling the boxstarter script and how @mwrock had originally set up his templates I noticed that he was calling it from the unattend and not from the provisioner step like I was. Going back and looking over his blog post regarding his templates I realized why he had done it that way, and so in my merging of his templates and box cutter windows I may take the same approach so that the boxstarter and updating at the very least happens before the reboot to begin provisioning.

On Jun 25, 2016, 9:12 AM, at 9:12 AM, Matt Caton notifications@github.com wrote:

@dragon788 Assuming we were sharing the same or similar issues (and
looking at your error log I think we are...) I have got this to work
from the following
link
. Basically
boiled down to an issue with running Boxstarter over a winrm session.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#12 (comment)

@dragon788
Copy link
Contributor

I think this could be considered closed. Per @mwrock if you want to use Invoke-Task directly (after importing Boxstarter.Common) you need to "prime the pump" with a manual (interactive) $cred = Get-Credential; Create-BoxstarterTask -Credential $cred or an automated password in plain text in your code, $secpasswd = ConvertTo-SecureString "vagrant" -AsPlainText -Force; $cred = New-Object System.Management.Automation.PSCredential ("vagrant", $secpasswd); Create-BoxstarterTask -Credential $cred BEFORE you try to Invoke-FromTask. Setting up the Boxstarter task caches the credentials and allows the Invoke to work properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants