Powershell script for ESX

Santosh Gupta
Santosh Gupta used Ask the Experts™
on
Hi Experts,

I need a Powershell script for ESX to run via ESXCLI for following tasks.

1. read file permission. (ex. /etc/X11/xinit/xinitrc.d/popup.sh) and save it to a file.
2. change the permission on file like chmod 775 /etc/X11/xinit/xinitrc.d/popup.sh
3. delete file

the task need to be run on list of esx servers.

Thanks in Advance.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017
Commented:
see here, because you can run native commands using this plugin

http://www.v-front.de/2013/01/release-esxcli-plugin-to-run-arbitrary.html

e.g.
esxcli shell ls -al  /etc/X11/xinit/xinitrc.d/popup.sh > acl.log

esxcli shell chmod 775 /etc/X11/xinit/xinitrc.d/popup.sh

Open in new window


However, which version of ESX or ESXi are you using?
Top Expert 2014

Author

Commented:
Hi,

Thanks for prompt response.

it seems its ESXCLI command. can we use it as script to run for  list of servers.

we are using ESX 3.5 and 4.1.

It is prompting me for password every time, can we save it once.

i am getting below error after running the command.

esxcli can only be used with version 4.0 or newer servers
Andrew Hancock (VMware vExpert / EE Fellow)VMware and Virtualization Consultant
Fellow 2018
Expert of the Year 2017

Commented:
Okay, your servers are too old, to use the esxcli plugin I listed.

you could do this using plink (ssh).
Top Expert 2014

Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial