Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Invoke PDQ Deploy Powershell Deployment with specific Credentials

Ive had a look around but havent been able to find anything yet.

Im looking to start a deployment via Powershell which i have seen the following code.

Invoke-Command -ComputerName "Fry" -ScriptBlock 
{
pdqdeploy Deploy -Package "Example Package" -Targets "Wolverine"
}

However i need this deployment to run with specific credentials. Is this possible? The above code would execute using the default credentials.

0

Comments

1 comment
Date Votes
  • Hello there!

    Since it sounds like you're running PowerShell to connect to a machine that you have PDQ Deploy installed on, I'll focus on the PowerShell.

    PowerShell's Invoke-Command has a -Credential parameter that accepts a PSCredential object. Check out the docs on it here: Invoke-Command

    So, if you're trying to run a scriptblock remotely on a different computer as a different user, you'll just need to provide the credential for that different user.

    There are a handful of ways that you can create a PSCredential object. If you're just interactively using PowerShell, the easiest way to do that is to use the Get-Credential cmdlet and store the resulting object into a variable:

    $MyCredential = Get-Credential 
    

    That will prompt you for a username and password and will create the PSCredential object for you. Then, you can use that new credential directly with Invoke-Command. Combining the above with your example:

    $MyCredential = Get-Credential 
    Invoke-Command -ComputerName "Fry" -Credential $MyCredential -ScriptBlock 
    {
    pdqdeploy Deploy -Package "Example Package" -Targets "Wolverine"
    }
    

    If you're looking for more info on credentials and how to securely use them, take a look at my blogs I wrote on the topic:

    I hope that helps! Best of luck to you!

    Cheers,

    0