Is it possible to read/modify a host file, such as "/etc/passwd", using PowerCLI? The only alternative method I know of would be to manually log in via TSM and use the basic linux-esque commands ("cat /etc/passwd", "vi /etc/passwd").
I realize that the majority of the things an administrator would want to read / modify are readily available via PowerCLI cmdlets that access most (or all?) of the vCenter-viewable configurations. However, as odd as it may be, I am specifically interested in reading / modifying the contents of entire host files themselves.
An example of something I'd like to do: Read the pam.d and related configuration files to determine the password-related controls enforced for console sessions & users. So far, I haven't seen this type of info readily available via a vCenter setting or report.
Thanks in advance and best regards.
*** Edit: I've only used ESXi 5 & vCenter in a Workstation environment, and I've just recently installed PowerCLI. I apologize for my limited knowledge, but my lack of time & resources lead me to ask questions early in the learning process
*** Edit: I'm also aware that there are PowerCLI commands that focus on log files. This is the type of functionality I'm interested in - however, I would like to view any file - within reason - on the host... not just the log files.
Edit: Just re-read your post. You are looking to automate grabbing files from the ESXi server, not from guests right? Information below is not going to work for that. This will automate grabbing files from guests. 😕
Hi. Sounds like you would want to use VIX. VIX allows you to interact with the guest OS via vCenter. So doesn't require network access, just an account on the guest with the correct rights.
VIX is easy enough to use in PowerCLI
If you want to copy a file to your host.
Get-VM theNameOfMyVM | Copy-VMGuestFile -GuestToLocal -Source "/etc/passwd" -Destination "c:\passwd" -GuestUser root -GuestPassword verysecurepassword -Confirm:$false
Then you can read it, make changes etc.
Copy file back.
Get-VM theNameOfMyVM | Copy-VMGuestFile -LocalToGuest -Source "c:\passwd" -Destination "/etc/passwd" -GuestUser Administrator -GuestPassword verysecurepassword -Confirm:$false
Maybe you want to run a script.
Get-VM theNameOfMyVM| Invoke-VMScript -GuestUser "root" -GuestPassword "verysecurepassword" -ScriptText "sudo chmod 777 /etc/passwd" -ScriptType Bash -RunAsync -Confirm:$false
Is this the kind of thing you are looking for?