Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Invoke-command with an expression fails to run on remote machine

$
0
0

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



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>