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

PSDeployScripts issue with using parameter sets #71

Open
DexterPOSH opened this issue Nov 28, 2016 · 2 comments
Open

PSDeployScripts issue with using parameter sets #71

DexterPOSH opened this issue Nov 28, 2016 · 2 comments

Comments

@DexterPOSH
Copy link
Contributor

While working on a new PSDeployment type for Scheduled task, came across this limitation with PSDeploy.

If there are parameter sets defined in the PSDeployScript e.g ScheduledTask.ps1, then Invoke-PSDeploy issues the warnings saying the parameters are not valid

[CmdletBinding(DefaultParameterSetName='SimpleTask')]
param(
    [ValidateScript({ $_.PSObject.TypeNames[0] -eq 'PSDeploy.Deployment' })]
    [psobject[]]$Deployment,

    # Specify the Computer name 
    [String]$ComputerName,
)
$ComputerName

Below is the sample PSDeploy.ps1 used :-

Deploy DeploymentToServer2016VM {
    $Credential = New-Object -TypeName PSCredential -ArgumentList 'Administrator',$(ConvertTo-SecureString -String 'p@ssw0rd#123' -AsPlainText -Force) 

    By ScheduledTask DeploySchedTask {
        FromSource 'MyTask.ps1'
        #To 'C:\PSDeployTo'
        Tagged Dev
        WithOptions @{
            ComputerName = 'WDS'
            Credential = $Credential
            RunAsUser = 'System'
            TaskName = 'MyTask'
            TaskAction = '"C:\Tasks\Mytask.ps1"'
            Once = $true
            At = $((Get-Date).AddMinutes(5))
        }
    }
}

The parameters are not even splatted to the deployment script.

PS C:\PSDeployFrom> Invoke-PSDeploy .\ScheduledTask.psdeploy.ps1 -Force
WARNING: WithOption 'RunAsUser' is not a valid parameter for 'ScheduledTask'
WARNING: WithOption 'Once' is not a valid parameter for 'ScheduledTask'
WARNING: WithOption 'ComputerName' is not a valid parameter for 'ScheduledTask'
WARNING: WithOption 'At' is not a valid parameter for 'ScheduledTask'
WARNING: WithOption 'TaskName' is not a valid parameter for 'ScheduledTask'
WARNING: WithOption 'Credential' is not a valid parameter for 'ScheduledTask'
WARNING: WithOption 'TaskAction' is not a valid parameter for 'ScheduledTask'
@DexterPOSH
Copy link
Contributor Author

@RamblingCookieMonster I have figured out a way to pull out the valid parameters based on the arguments passed from the scriptblock passed to WithOptions.

I am clubbing them together in the same branch used for the ScheduledTask deployment type.

@DexterPOSH
Copy link
Contributor Author

This commit in the branch 'feature_schtask', which fixes this issue.

DexterPOSH@3f1fb77

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

2 participants