Script to get VMName, Installed vmtools version, ToolsStatus, ToolsRunningStatus, PowerState, details and export to .csv or send over mail

 

 

PowerShell script to generate VMTool status report

Open Windows PowerShell ISE and run below command to save user ID and password in encrypted file.

$credential = Get-Credential

$credential.Password | ConvertFrom-SecureString | Set-Content c:\temp\password2.txt





now you will see one .txt file has created at below path

c:\temp\password2.txt

Run below command to check vCenter connectivity

Connect-VIServer -server vc6.ads.com -Credential $credential


Run below command to generate report and export at some location

$report = Get-VM | Get-View | Select-Object @{N=”VM Name”;E={$_.Name}},@{Name=”VMware Tools”;E={$_.Guest.ToolsStatus}} | Export-CSV c:\temp\VMwareToolsStatus.csv



Now you will see one file has created at given path



Save below PSCommand in .ps1 file and run it to get VMTool report

$credential = Get-Credential

$credential.Password | ConvertFrom-SecureString | Set-Content c:\temp\password1.txt

Connect-VIServer -server vc6.ads.com -Credential $credential

#$credential =Get-VICredentialStoreItem -File "C:\temp\password1.txt"

#$credential = Get-VICredentialStoreItem -file C:\temp\password1.xml

$report = Get-VM | Get-View | Select-Object @{N=”VM Name”;E={$_.Name}},@{Name=”VMware Tools”;E={$_.Guest.ToolsStatus}} | Export-CSV c:\temp\VMwareToolsStatus3.csv


Script to get VMName, Installed vmtools version, ToolsStatus, ToolsRunningStatus, PowerState, details and export to .csv or send over mail 

$credential = Get-Credential
$credential.Password | ConvertFrom-SecureString | Set-Content c:\temp\password1.txt
Connect-VIServer -server vc6.ads.com -Credential $credential
Get-VM | Select @{N=”VMName”; E={$_.Name}},@{N=”HardwareVersion”; E={$_.Extensiondata.Config.Version}},@{N=”ToolsVersion”; E={$_.Extensiondata.Config.Tools.ToolsVersion}},@{N=”ToolsStatus”; E={$_.Extensiondata.Summary.Guest.ToolsStatus}},@{N=”ToolsVersionStatus”; E={$_.Extensiondata.Summary.Guest.ToolsVersionStatus}},@{N=”ToolsRunningStatus”; E={$_.Extensiondata.Summary.Guest.ToolsRunningStatus}},PowerState | Export-CSV c:\temp\VMwareToolsStatus33.csv -NoTypeInformation -UseCulture

Send-MailMessage –From VMTool@domain.com –To raju.prasad01@domain.com –Subject “Guess what!” -Attachment "VMwareToolsStatus3.csv" –Body “I am Testing to get VMTool service status from PowerShell” -SmtpServer mail.ads.corp -UseSsl -Port 25

1 comment:

Featured Post

HPE MSA 2040 configuration step by step

HPE MSA 2040 configuration Default IP range for HP SAN storage MSA 2040 is 10.0.0.1/2 You need to connect your laptop and storage with...