Hi all,
So I'm able to create the msinfo32 info report using Invoke-VMScript -Examples.
I found an example online that opens that file in Notepad on guest machine
http://www.amikkelsen.com/?p=357
For script
$script = '&"notepad.exe" "$env:Tmp\inforeport.txt"'
For bat
$script = '"notepad.exe" "%Tmp%\inforeport.txt"'
Can't get neither to work. Do I need to grant some sort of permission on the guestVM? It locks up on me and no error messages. I looked at event log too, and nothing.
What do you get back from the Invoke-VMScript cmdlet ?
Any errors or messages ?
Perhaps show us how you called the Invoke-VMScript cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
#This runs fine, it creates the file remotely as intended.
$VM = get-vm -name "myVM"
#$script = '"%programfiles%\Common Files\Microsoft Shared\MSInfo\msinfo32.exe" /report "%tmp%\inforeport.txt"'
Invoke-VMScript -vm $VM -ScriptText $script -HostUser 'root' -HostPassword 'myPass' -GuestUser 'guestUser' -GuestPassword 'myPass -ScriptType Bat
#But this doesn't...no errors, just locks up. Nothing in event log.
$VM = get-vm -name "myVM"
$script = '"notepad.exe" "%Tmp%\inforeport.txt"'
Invoke-VMScript -vm $VM -ScriptText $script -HostUser 'root' -HostPassword 'myPass' -GuestUser 'guestUser' -GuestPassword 'myPass -ScriptType Bat
The problem is that you are starting an interactive application (notepad.exe), and the application keeps waiting for your input.
You will not see the application on screen, even though you have a session open with the same credentials.
$VM = Get-VM -name MyVM
$script = 'notepad.exe %Tmp%\test.txt'
Invoke-VMScript -vm $VM -ScriptText $script -GuestUser 'domain\user' -GuestPassword 'password' -ScriptType Bat
You can see the task running with TaskManager or Process Explorer.
You will have to kill the application from TaskManager or Process Explorer.
You can't run interactive applications through Invoke-VMScript (unless you provide input through the same script you launched with Invoke-VMScript.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference