Running PowerShell in SIF using the Command Task

Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I am trying to build out some simple PowerShell tasks into SIF tasks, and I am really hitting a wall with the simplest stuff. My estimation is that a Command task is for exe and console apps and not PowerShell commands. Example below.
My JSON configuration file dsc.json
"Parameters":
"InstallPath":
"Type": "Command",
"DefaultValue": "Start-DscConfiguration",
"Description": "DSC Install Path."
,
"Tasks":
"Test-Get-Children":
"Type": "Command",
"Params":
"Path": "Get-ChildItem",
"Arguments": [
"-Path",
"*.log"
]
,
"Test-DSC":
"Type": "Command",
"Params":
"Path": "Start-DscConfiguration",
"Arguments": [
"-Path",
".//Sitecore",
"-Wait",
"-Verbose"
]
My Parameters PS1 file.
$configsRoot = Join-Path $PSScriptRoot Configs
$sitecoreDSC = @
Path = Join-Path $configsRoot dsc.json
echo $sitecoreDSC
My install PS1 file
. $PSScriptRootparameters.ps1
Install-SitecoreConfiguration @sitecoreDSC
On the Get-Children command my error is this. It seems like it is trying to run the arg on its on command:
Get-ChildItem : Cannot find path 'C:ghScriptTestPrepServer-Path' because it does not exist.
At C:Program FilesWindowsPowerShellModulesSitecoreInstallFramework1.2.1PublicTasksInvoke-CommandTask.ps1:31 char:13
+ & $Path $Arguments | Out-Default
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:ghScriptTestPrepServer-Path:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
On the Start-DscConfiguration my error is this. This is because Start-DscConfiguration was executed with specifying the path. Again, the args were ignored.
Invoke-CommandTask : Cannot convert 'System.Management.Automation.PSObject' to the type 'System.String' required by parameter 'Path'. Specified method is not supported.
At C:Program FilesWindowsPowerShellModulesSitecoreInstallFramework1.2.1PublicInstall-SitecoreConfiguration.ps1:253 char:21
+ & $entry.Task.Command @paramSet | Out-Default
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-CommandTask
sitecore-install-framework
add a comment |Â
up vote
3
down vote
favorite
I am trying to build out some simple PowerShell tasks into SIF tasks, and I am really hitting a wall with the simplest stuff. My estimation is that a Command task is for exe and console apps and not PowerShell commands. Example below.
My JSON configuration file dsc.json
"Parameters":
"InstallPath":
"Type": "Command",
"DefaultValue": "Start-DscConfiguration",
"Description": "DSC Install Path."
,
"Tasks":
"Test-Get-Children":
"Type": "Command",
"Params":
"Path": "Get-ChildItem",
"Arguments": [
"-Path",
"*.log"
]
,
"Test-DSC":
"Type": "Command",
"Params":
"Path": "Start-DscConfiguration",
"Arguments": [
"-Path",
".//Sitecore",
"-Wait",
"-Verbose"
]
My Parameters PS1 file.
$configsRoot = Join-Path $PSScriptRoot Configs
$sitecoreDSC = @
Path = Join-Path $configsRoot dsc.json
echo $sitecoreDSC
My install PS1 file
. $PSScriptRootparameters.ps1
Install-SitecoreConfiguration @sitecoreDSC
On the Get-Children command my error is this. It seems like it is trying to run the arg on its on command:
Get-ChildItem : Cannot find path 'C:ghScriptTestPrepServer-Path' because it does not exist.
At C:Program FilesWindowsPowerShellModulesSitecoreInstallFramework1.2.1PublicTasksInvoke-CommandTask.ps1:31 char:13
+ & $Path $Arguments | Out-Default
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:ghScriptTestPrepServer-Path:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
On the Start-DscConfiguration my error is this. This is because Start-DscConfiguration was executed with specifying the path. Again, the args were ignored.
Invoke-CommandTask : Cannot convert 'System.Management.Automation.PSObject' to the type 'System.String' required by parameter 'Path'. Specified method is not supported.
At C:Program FilesWindowsPowerShellModulesSitecoreInstallFramework1.2.1PublicInstall-SitecoreConfiguration.ps1:253 char:21
+ & $entry.Task.Command @paramSet | Out-Default
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-CommandTask
sitecore-install-framework
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I am trying to build out some simple PowerShell tasks into SIF tasks, and I am really hitting a wall with the simplest stuff. My estimation is that a Command task is for exe and console apps and not PowerShell commands. Example below.
My JSON configuration file dsc.json
"Parameters":
"InstallPath":
"Type": "Command",
"DefaultValue": "Start-DscConfiguration",
"Description": "DSC Install Path."
,
"Tasks":
"Test-Get-Children":
"Type": "Command",
"Params":
"Path": "Get-ChildItem",
"Arguments": [
"-Path",
"*.log"
]
,
"Test-DSC":
"Type": "Command",
"Params":
"Path": "Start-DscConfiguration",
"Arguments": [
"-Path",
".//Sitecore",
"-Wait",
"-Verbose"
]
My Parameters PS1 file.
$configsRoot = Join-Path $PSScriptRoot Configs
$sitecoreDSC = @
Path = Join-Path $configsRoot dsc.json
echo $sitecoreDSC
My install PS1 file
. $PSScriptRootparameters.ps1
Install-SitecoreConfiguration @sitecoreDSC
On the Get-Children command my error is this. It seems like it is trying to run the arg on its on command:
Get-ChildItem : Cannot find path 'C:ghScriptTestPrepServer-Path' because it does not exist.
At C:Program FilesWindowsPowerShellModulesSitecoreInstallFramework1.2.1PublicTasksInvoke-CommandTask.ps1:31 char:13
+ & $Path $Arguments | Out-Default
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:ghScriptTestPrepServer-Path:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
On the Start-DscConfiguration my error is this. This is because Start-DscConfiguration was executed with specifying the path. Again, the args were ignored.
Invoke-CommandTask : Cannot convert 'System.Management.Automation.PSObject' to the type 'System.String' required by parameter 'Path'. Specified method is not supported.
At C:Program FilesWindowsPowerShellModulesSitecoreInstallFramework1.2.1PublicInstall-SitecoreConfiguration.ps1:253 char:21
+ & $entry.Task.Command @paramSet | Out-Default
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-CommandTask
sitecore-install-framework
I am trying to build out some simple PowerShell tasks into SIF tasks, and I am really hitting a wall with the simplest stuff. My estimation is that a Command task is for exe and console apps and not PowerShell commands. Example below.
My JSON configuration file dsc.json
"Parameters":
"InstallPath":
"Type": "Command",
"DefaultValue": "Start-DscConfiguration",
"Description": "DSC Install Path."
,
"Tasks":
"Test-Get-Children":
"Type": "Command",
"Params":
"Path": "Get-ChildItem",
"Arguments": [
"-Path",
"*.log"
]
,
"Test-DSC":
"Type": "Command",
"Params":
"Path": "Start-DscConfiguration",
"Arguments": [
"-Path",
".//Sitecore",
"-Wait",
"-Verbose"
]
My Parameters PS1 file.
$configsRoot = Join-Path $PSScriptRoot Configs
$sitecoreDSC = @
Path = Join-Path $configsRoot dsc.json
echo $sitecoreDSC
My install PS1 file
. $PSScriptRootparameters.ps1
Install-SitecoreConfiguration @sitecoreDSC
On the Get-Children command my error is this. It seems like it is trying to run the arg on its on command:
Get-ChildItem : Cannot find path 'C:ghScriptTestPrepServer-Path' because it does not exist.
At C:Program FilesWindowsPowerShellModulesSitecoreInstallFramework1.2.1PublicTasksInvoke-CommandTask.ps1:31 char:13
+ & $Path $Arguments | Out-Default
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:ghScriptTestPrepServer-Path:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
On the Start-DscConfiguration my error is this. This is because Start-DscConfiguration was executed with specifying the path. Again, the args were ignored.
Invoke-CommandTask : Cannot convert 'System.Management.Automation.PSObject' to the type 'System.String' required by parameter 'Path'. Specified method is not supported.
At C:Program FilesWindowsPowerShellModulesSitecoreInstallFramework1.2.1PublicInstall-SitecoreConfiguration.ps1:253 char:21
+ & $entry.Task.Command @paramSet | Out-Default
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-CommandTask
sitecore-install-framework
asked Aug 11 at 18:23
Chris Auer
6,0761737
6,0761737
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
Correct. Try running Get-Help Invoke-CommandTask to see the documentation and guidance on the built in command task.
You can import arbitrary powershell functions by registering them in a custom module.
- Create a psm1 file
- In the psm1, use
Register-SitecoreInstallExtensionto register the function as a task - Add the psm1 in the modules section of your config
This will enable you to register existing or custom functions into the scope of your install.
E.g. Register-SitecoreInstallExtension -Command Start-DSConfiguration -As StartDSC -Type Task
Will enable you to use the task type StartDSC in your config.
In SIF V2, this will be even easier as a new feature simplifies custom function registration.
If you really need or want to put raw powershell in your config, check out SIX
The configuration guide available at: dev.sitecore.net/Downloads/Sitecore_Installation_Framework/1x/⦠should explain things further
â Kieranties
Aug 11 at 19:51
I started to do this in a repo of SIX and switched to tasks thinking it would be more consistent. Maybe I will just go back to that route. Thanks.
â Chris Auer
Aug 11 at 20:02
Tasks will be simpler and easier to share as raw PowerShell in configs will be more difficult to modify. Registration is really simple. Please also check the examples here (notably 6.modules.json and the extensions.psm1) github.com/Kieranties/SIfSug/tree/master/Examples
â Kieranties
Aug 11 at 20:06
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
Correct. Try running Get-Help Invoke-CommandTask to see the documentation and guidance on the built in command task.
You can import arbitrary powershell functions by registering them in a custom module.
- Create a psm1 file
- In the psm1, use
Register-SitecoreInstallExtensionto register the function as a task - Add the psm1 in the modules section of your config
This will enable you to register existing or custom functions into the scope of your install.
E.g. Register-SitecoreInstallExtension -Command Start-DSConfiguration -As StartDSC -Type Task
Will enable you to use the task type StartDSC in your config.
In SIF V2, this will be even easier as a new feature simplifies custom function registration.
If you really need or want to put raw powershell in your config, check out SIX
The configuration guide available at: dev.sitecore.net/Downloads/Sitecore_Installation_Framework/1x/⦠should explain things further
â Kieranties
Aug 11 at 19:51
I started to do this in a repo of SIX and switched to tasks thinking it would be more consistent. Maybe I will just go back to that route. Thanks.
â Chris Auer
Aug 11 at 20:02
Tasks will be simpler and easier to share as raw PowerShell in configs will be more difficult to modify. Registration is really simple. Please also check the examples here (notably 6.modules.json and the extensions.psm1) github.com/Kieranties/SIfSug/tree/master/Examples
â Kieranties
Aug 11 at 20:06
add a comment |Â
up vote
3
down vote
accepted
Correct. Try running Get-Help Invoke-CommandTask to see the documentation and guidance on the built in command task.
You can import arbitrary powershell functions by registering them in a custom module.
- Create a psm1 file
- In the psm1, use
Register-SitecoreInstallExtensionto register the function as a task - Add the psm1 in the modules section of your config
This will enable you to register existing or custom functions into the scope of your install.
E.g. Register-SitecoreInstallExtension -Command Start-DSConfiguration -As StartDSC -Type Task
Will enable you to use the task type StartDSC in your config.
In SIF V2, this will be even easier as a new feature simplifies custom function registration.
If you really need or want to put raw powershell in your config, check out SIX
The configuration guide available at: dev.sitecore.net/Downloads/Sitecore_Installation_Framework/1x/⦠should explain things further
â Kieranties
Aug 11 at 19:51
I started to do this in a repo of SIX and switched to tasks thinking it would be more consistent. Maybe I will just go back to that route. Thanks.
â Chris Auer
Aug 11 at 20:02
Tasks will be simpler and easier to share as raw PowerShell in configs will be more difficult to modify. Registration is really simple. Please also check the examples here (notably 6.modules.json and the extensions.psm1) github.com/Kieranties/SIfSug/tree/master/Examples
â Kieranties
Aug 11 at 20:06
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
Correct. Try running Get-Help Invoke-CommandTask to see the documentation and guidance on the built in command task.
You can import arbitrary powershell functions by registering them in a custom module.
- Create a psm1 file
- In the psm1, use
Register-SitecoreInstallExtensionto register the function as a task - Add the psm1 in the modules section of your config
This will enable you to register existing or custom functions into the scope of your install.
E.g. Register-SitecoreInstallExtension -Command Start-DSConfiguration -As StartDSC -Type Task
Will enable you to use the task type StartDSC in your config.
In SIF V2, this will be even easier as a new feature simplifies custom function registration.
If you really need or want to put raw powershell in your config, check out SIX
Correct. Try running Get-Help Invoke-CommandTask to see the documentation and guidance on the built in command task.
You can import arbitrary powershell functions by registering them in a custom module.
- Create a psm1 file
- In the psm1, use
Register-SitecoreInstallExtensionto register the function as a task - Add the psm1 in the modules section of your config
This will enable you to register existing or custom functions into the scope of your install.
E.g. Register-SitecoreInstallExtension -Command Start-DSConfiguration -As StartDSC -Type Task
Will enable you to use the task type StartDSC in your config.
In SIF V2, this will be even easier as a new feature simplifies custom function registration.
If you really need or want to put raw powershell in your config, check out SIX
edited Aug 11 at 19:53
answered Aug 11 at 19:48
Kieranties
47126
47126
The configuration guide available at: dev.sitecore.net/Downloads/Sitecore_Installation_Framework/1x/⦠should explain things further
â Kieranties
Aug 11 at 19:51
I started to do this in a repo of SIX and switched to tasks thinking it would be more consistent. Maybe I will just go back to that route. Thanks.
â Chris Auer
Aug 11 at 20:02
Tasks will be simpler and easier to share as raw PowerShell in configs will be more difficult to modify. Registration is really simple. Please also check the examples here (notably 6.modules.json and the extensions.psm1) github.com/Kieranties/SIfSug/tree/master/Examples
â Kieranties
Aug 11 at 20:06
add a comment |Â
The configuration guide available at: dev.sitecore.net/Downloads/Sitecore_Installation_Framework/1x/⦠should explain things further
â Kieranties
Aug 11 at 19:51
I started to do this in a repo of SIX and switched to tasks thinking it would be more consistent. Maybe I will just go back to that route. Thanks.
â Chris Auer
Aug 11 at 20:02
Tasks will be simpler and easier to share as raw PowerShell in configs will be more difficult to modify. Registration is really simple. Please also check the examples here (notably 6.modules.json and the extensions.psm1) github.com/Kieranties/SIfSug/tree/master/Examples
â Kieranties
Aug 11 at 20:06
The configuration guide available at: dev.sitecore.net/Downloads/Sitecore_Installation_Framework/1x/⦠should explain things further
â Kieranties
Aug 11 at 19:51
The configuration guide available at: dev.sitecore.net/Downloads/Sitecore_Installation_Framework/1x/⦠should explain things further
â Kieranties
Aug 11 at 19:51
I started to do this in a repo of SIX and switched to tasks thinking it would be more consistent. Maybe I will just go back to that route. Thanks.
â Chris Auer
Aug 11 at 20:02
I started to do this in a repo of SIX and switched to tasks thinking it would be more consistent. Maybe I will just go back to that route. Thanks.
â Chris Auer
Aug 11 at 20:02
Tasks will be simpler and easier to share as raw PowerShell in configs will be more difficult to modify. Registration is really simple. Please also check the examples here (notably 6.modules.json and the extensions.psm1) github.com/Kieranties/SIfSug/tree/master/Examples
â Kieranties
Aug 11 at 20:06
Tasks will be simpler and easier to share as raw PowerShell in configs will be more difficult to modify. Registration is really simple. Please also check the examples here (notably 6.modules.json and the extensions.psm1) github.com/Kieranties/SIfSug/tree/master/Examples
â Kieranties
Aug 11 at 20:06
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f13304%2frunning-powershell-in-sif-using-the-command-task%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password