Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 170134

Re: powershell command to take remote session and execute .bat file``

$
0
0

I'M able to take the remote session.now need to invoke powershell script for remote installation of Vcenter5.1.For SSO installation we’ve written logic somewhat like this:

 

$username = "Administrator"

$password = "crt@123"

$Server = "10.211.34.2"

$secstr = New-Object -TypeName System.Security.SecureString

$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr

$session=New-PSsession -Computername $Server -Credential $cred

 

Invoke-Command -Session $session -ScriptBlock {&"c:\batch_files\inventory.bat"}

 

In above code we’re taking username and password from xml file. It is taking remote session successfully & on local m/c ‘s console it is showing contents of the bat file and get stucked there only. We searched for Remote installation of bat file commands they are using ‘Invoke-Command’ only. But in our case neither the installation get started nor it is showing error. 

 




Viewing all articles
Browse latest Browse all 170134

Trending Articles



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