We need to run some commands inside one of the vm , but its not connect to the network
First we need to connect to the vCenter using powercli
In below command I’m using dos command to create a folder in c drive of the vm
Code
connect-viserver vcenter.corp.local
$cred=Get-Credential
Invoke-VMScript –vm vm01 –ScriptText “mkdir C:\Test” –ScriptType Bat –GuestCredential $cred
Same way we can run the PowerShell commands(In below example, I’m stopping the spooler service)
connect-viserver vcenter.corp.local
$cred=Get-Credential
Invoke-VMScript –vm vm01 –ScriptText “stop-service spoooler” –ScriptType Powershell –GuestCredential $cred