Powercli run commands inside the vm without network connectivity

We need to run some commands inside one of the vm , but its not connect to the network

image

First we need to connect to the vCenter using powercli

image

In below command I’m using dos command to create a folder in c drive of the vm

image

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.