Hello,
i need to install vmware tools on few windows 7 vms
i came across
ie
msiexec /i "VMware Tools.msi" ADDLOCAL=ALL REMOVE="Hgfs,WYSE,GuestSDK,vmdesched" /qn /l* C:\temp\toolsinst.log /norestart
Also something of sort below ..
https://gist.github.com/sneal/eeb52e859186ba44163d
(New-Object System.Net.WebClient).DownloadFile($download_url, "c:\windows\temp\$iso_name") | |
&c:\7-zip\7z.exe x "c:\windows\temp\$iso_name" -oc:\windows\temp\vmware -aoa | Out-Host | |
&c:\windows\temp\vmware\setup.exe /S /v`"/qn REBOOT=R`" | Out-Host |
i have used,
And have mounted the ISO
Can somehow we can do this automation with powercli or powershell ?
I want to use domain id & if that does not work a local admin account to comeplete the install.
When the ISO is mounted in the VM, you could use the Invoke-Command cmdlet with the ComputerName parameter, to remotely start the setup.exe.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD
I found below in our forum ..
Import-Module VMware.VimAutomation.Cis.Core
Import-Module VMware.VimAutomation.Core
Import-Module VMware.VimAutomation.HA
Import-Module VMware.VimAutomation.Sdk
Import-Module VMware.VimAutomation.Storage
Import-Module VMware.VimAutomation.Vds
$username = "xx"
$password = "xx" | ConvertTo-SecureString -asPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential ($username,$password)
$VM = "xx"
Get-vm $VM | Dismount-Tools
Get-vm $VM | Mount-Tools
$RMsession = New-PSSession -ComputerName $VM -Credential $Credentials
Invoke-Command -Session $RMSession -ScriptBlock {$CDRom = Get-WmiObject -class Win32_CDROMDrive | select Drive | ForEach {$_.Drive}}
Invoke-Command -Session $RMSession -ScriptBlock {$Subpath = '\setup.exe -s -v-qn ADDLOCAL=ALL REBOOT=R'}
Invoke-Command -Session $RMSession -ScriptBlock {$ExecuteEXE = Join-Path -Path $CDRom -ChildPath $Subpath}
Invoke-Command -Session $RMSession -ScriptBlock {start-process $executeEXE}
==
Err
New-PSSession : One or more computer names are not valid. If you are trying to pass a URI, use the -ConnectionUri parameter, or pass URI objects instead of strings.
At line:1 char:17
+ $RMsession = New-PSSession -ComputerName $VM -Credential $Credentials
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (System.String[]:String[]) [New-PSSession], ArgumentException
+ FullyQualifiedErrorId : PSSessionInvalidComputerName,Microsoft.PowerShell.Commands.NewPSSessionCommand
===
Any suggestion Please
PowerCLI C:\> $RMsession = New-PSSession -ComputerName $VM -Credential $Credentials |
New-PSSession : [xx-xx] Connecting to remote server xx-xx failed with the following error message : WinRM cannot complete the operati
At line:1 char:17
+ $RMsession = New-PSSession -ComputerName $VM -Credential $Credentials
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : WinRMOperationTimeout,PSSessionOpenFailed
Above is new err
fixed with
https://technet.microsoft.com/en-us/magazine/ff700227.aspx
now i get the err
This command cannot be executed due to the error: The system cannot find the file specified.
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
+ PSComputerName : xx-xx
WinRM is all set
I tested that works fine with
Invoke-Command -ComputerName $VM -Credential $Credentials -ScriptBlock { Get-ChildItem C:\ }
Is the CD available inside the guest OS after the Mount-Tools cmdlet?
From the error it looks it isn't.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It is available
i can see files
PowerCLI C:\> Invoke-Command -ComputerName $VM -Credential $Credentials -ScriptBlock { Get-ChildItem D:\ }
Directory: D:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 8/20/2015 4:08 AM Program Files
--r-- 8/20/2015 4:08 AM 599232 VMwareToolsUpgrader.exe
--r-- 8/20/2015 4:08 AM 55802 autorun.ico
--r-- 8/20/2015 4:08 AM 100 autorun.inf
--r-- 8/20/2015 4:08 AM 23 certified.txt
--r-- 8/20/2015 4:08 AM 2953 manifest.txt
--r-- 8/20/2015 4:08 AM 38275672 setup.exe
--r-- 8/20/2015 4:08 AM 49833632 setup64.exe
The error seems to be indicating that the setup.exe is not found.
Could you show the script/commands you are using?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
not clear what you need
but the script is below one
$VM = "xx"
Get-vm $VM | Dismount-Tools
Get-vm $VM | Mount-Tools
$RMsession = New-PSSession -ComputerName $VM -Credential $Credentials
Invoke-Command -Session $RMSession -ScriptBlock {$CDRom = Get-WmiObject -class Win32_CDROMDrive | select Drive | ForEach {$_.Drive}}
Invoke-Command -Session $RMSession -ScriptBlock {$Subpath = '\setup.exe -s -v-qn ADDLOCAL=ALL REBOOT=R'}
Invoke-Command -Session $RMSession -ScriptBlock {$ExecuteEXE = Join-Path -Path $CDRom -ChildPath $Subpath}
Invoke-Command -Session $RMSession -ScriptBlock {start-process $executeEXE}
Can you try like this?
$VM = "xx"
Get-vm $VM | Dismount-Tools
Get-vm $VM | Mount-Tools
$RMsession = New-PSSession -ComputerName $VM -Credential $Credentials
Invoke-Command -Session $RMSession -ScriptBlock {
$CDRom = Get-WmiObject -class Win32_CDROMDrive | select Drive | ForEach {$_.Drive}
$setExe = '\setup.exe'
$arguments = '-s -v-qn ADDLOCAL=ALL REBOOT=R'
$ExecuteEXE = Join-Path -Path $CDRom -ChildPath $setExe
Start-Process -FilePath $executeEXE -ArgumentList $arguments
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD
This time the script ran with no err
But the tools are not installed
I waited for 15 min now.
i did not see in "active task" any message saying tools are being installed
Can you try running the lines in the scriptblock directly inside the guest OS?
I'm wondering if there might be a prompt or a message, that makes the remote job hang as well
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Perhaps I was not clear, but I wanted to see the setup.exe being started form a command prompt or PowerShell prompt, with the same parameters you are passing to the Invoke-VMScript.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
i mounted the cdrom & ran directly on OS
$CDRom = Get-WmiObject -class Win32_CDROMDrive | select Drive | ForEach {$_.Drive}
$setExe = '\setup.exe'
$arguments = '-s -v-qn ADDLOCAL=ALL REBOOT=R'
$ExecuteEXE = Join-Path -Path $CDRom -ChildPath $setExe
Start-Process -FilePath $executeEXE -ArgumentList $arguments
No err but tools are not installed
Ok, leave out the 'qn' parameter, that way the installation will not be silent anymore.
And you should see what is happening
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference