$command = {
{& C:\Users\mnmicrostrategy\Desktop\MSTRTrigger\TCargaVenda.bat}
}
$user = "jkf\badumtsss"
$password = "pass"
$target = "APOLLO"
$secpassword = $password | ConvertTo-SecureString -AsPlainText -Force
$creds = New-Object ystem.Management.Automation.PSCredential($user,$secpassword)
Invoke-Command -ComputerName $target -Credential $creds -ScriptBlock {$command}
I'm trying to run the above powershell script on my local machine to connect on a windows server machine called "APOLLO" and execute an .bat script
When I run manually my .bat on server I got success on execution, and I receive the notification e-mail, but, when I run from power shell script to remote connect and executes the .bat, I got no errors and nothing happens.
PS: I have the powershell -executionpolicy remotesigned on my local machine.
Some help will be appreciated. Thank you all.
The below script works for me, thanks!
$user = "jfk\baduntsss"
$password = "ueaohuheaou"
$target = "APOLLO"
$secpassword = $password | ConvertTo-SecureString -AsPlainText -Force
$Creds = New-Object
System.Management.Automation.PSCredential($user,$secpassword)
Invoke-Command -ComputerName $target -Credential $Creds -ScriptBlock {&
C:\Users\mnmicrostrategy\Desktop\MSTRTrigger\TCargaVenda.bat}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.