Im attempting to run an expression on a remote machine
Run locally the following works
$Msdeploy = "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" $Expression = "& '$($MsDeploy)' -verb:sync -source:apphostconfig=monitor -dest:package='c:\sites2\monitor.zip,encryptPassword='PASSWORD'' > DWSpackage7.log" Invoke-Expression $Expression
when i attempt to run this i get nothing , i have the invoke command working this way for other aspects of the script.
$password = cat e:\~Scripts\securepasstestiis.txt | convertto-securestring
$user = "***\*******"
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $user,$password
$Msdeploy = "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
$site = "Monitor"
$Expression = "& '$($MsDeploy)' -verb:sync -source:apphostconfig=monitor -dest:package='c:\sites2\monitor2.zip,encryptPassword='PASSWORD'' > DWSpackage7.log"
#Invoke-Expression –computerName deploytest1 $Expression -credential $cred
#Invoke-Command -ComputerName deploytest1 $Expression -credential $cred
Invoke-Command -ComputerName deploytest1 -ScriptBlock {
$Expression
} -credential $cred