Invoke PDQ Deploy Powershell Deployment with specific Credentials
Danny Borg
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
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:
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:
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,