Advertisement
Guest User

Remote Deploy Remotely!

a guest
Feb 11th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. .SYNOPSIS
  3.   Invokes a new deployment from the PDQ install on a remote computer.
  4.  
  5. .DESCRIPTION
  6.   This command allows you to deploy any package found in PDQ Deploy remotely from command line.
  7.  
  8. .EXAMPLE
  9.   New-PDQDeployment -package "Flash Player" -targets "001-Computer" -credentials $(Get-Credential -UserName domain\admin)
  10. #>
  11. Function New-PDQDeployment {
  12.   [CmdletBinding()]
  13.   Param (
  14.     # Param1 help description
  15.     [Parameter()]
  16.     $Package,
  17.     [Parameter()]
  18.     $Targets,
  19.     [Parameter()]
  20.     $Credentials
  21.   )
  22.   Begin {
  23.     $s = New-PSSession -Credential $Credentials -computerName yourServerNameHere
  24.   }
  25.   Process {
  26.     Invoke-Command -Session $s -Verbose -Scriptblock{
  27.     $pdqfolder = "C:\Program Files (x86)\Admin Arsenal\PDQ Deploy\";
  28.     cd $pdqfolder;
  29.     .\pdqdeploy.exe Deploy -Package $args[0] -Targets $args[1]
  30.     } -args @($Package,$Targets)
  31.   }
  32.  
  33.   End {
  34.     Remove-PSSession $s
  35.   }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement