Quantcast
Viewing all articles
Browse latest Browse all 49146

html_report_powercli

Hi Luc ,

 

Good morning ,

I had a discussion with you earlier to generate html report for a cluster .

i am trying to loop it on a list of clusters using import-csv.

However for some reasons not getting desired  output  .can you please check and modify it .

 

 

$vc=read-host "specify vcenter name"

$cred=Get-Credential

 

connect-viserver -server $vc -Credential $cred|out-null

 

$path = 'C:\Users\user1\Desktop\folder1'

 

 

 

$head = @'

 

<style>

 

body { background-color:#dddddd;

 

       font-family:Tahoma;

 

       font-size:12pt; }

 

td, th { border:1px solid black;

 

         border-collapse:collapse; }

 

th { color:white;

 

     background-color:black; }

 

table, tr, td, th { padding: 2px; margin: 0px }

 

table { margin-left:50px; }

 

</style>

 

'@

 

 

$clusters = Import-Csv -path  "C:\users\user1\desktop\folder1\names.csv"

 

 

foreach($line in $clusters)

{

 

$cluster = Get-Cluster -name $line.clustername

$clu = Get-Cluster -name $cluster|select name|convertto-html -property name -Fragment -PreContent '<h2>clustername </h2>'|out-string

 

$ds_all=get-datastore -RelatedObject $cluster

$syslog_server="10.x.x.x"

 

 

$ds = Get-Datastore -RelatedObject $cluster |

 

    Where-Object{($_.FreeSpaceGB)/($_.CapacityGB) -le 0.15} |

 

    Select Name |

 

    ConvertTo-Html -Property Name -Fragment -PreContent '<h2>DATASTORE WITH LESS THAN 15 PERCENT SPACE </h2>' |

 

    Out-String

 

 

 

$snap = Get-VM -location $cluster  | Get-Snapshot |

 

    Select Name,@{N='VM';E={$_.VM.Name}},Created |

 

 

      ConvertTo-Html -Property Name,VM,Created -Fragment -PreContent '<h2>SNAPSHOT_INFO</h2>' |

 

    Out-String

 

 

  

 

 

 

$powered_off=get-vm -Location $cluster|?{$_.PowerState -eq "poweredoff"}|select name|

    ConvertTo-Html -Property Name -Fragment -PreContent '<h2>POWEREDOFF_VMS</h2>' |

 

    Out-String

 

 

   

 

 

 

$vmkernel_vmotion = Get-VMHost -Location $cluster|select name,@{N='vmkernel';E={$_|get-vmhostnetworkadapter -VMKernel|?{$_.vmotionenabled -eq "true"}}}| ConvertTo-Html -Property name,vmkernel -Fragment -PreContent '<h2>VMKERNEL_PORT_VMOTION</h2>' |

 

    Out-String

 

$syslog_server=Get-VMHost -Location $cluster|select name,@{N='syslogserver';E={Get-VMHostSysLogServer -VMHost $_}}|ConvertTo-Html -Property name,syslogserver -Fragment -PreContent '<h2>SYSLOGSERVER<h2>' | out-string

 

 

 

 

 

 

$windows_vm_tooldsupgrde_needed=get-vm -Location $cluster|?{$_.Guest.GuestFamily -eq 'windowsGuest' -and $_.ExtensionData.guest.toolsversionstatus -eq 'guesttoolsneedupgrade'}|select name|

ConvertTo-Html -Property Name -Fragment -PreContent '<h2>WINDOWS_VM_TOOLS_NEED_UPGRADE</h2>' |

 

    Out-String

 

 

$ntp = get-vmhost -Location $cluster|Get-VMHostService|?{$_.key -eq 'ntpd'}|select vmhost,key,running|ConvertTo-Html -Property vmhost,key,running -Fragment -precontent '<h2>NTP<h2>'|Out-String

$version=get-vmhost -location $cluster|select name,build,version,model|ConvertTo-Html -Property name,build,version,model -Fragment -PreContent '<h2>VERSION<h2>'|Out-String

 

 

 

 

 

$cluster_properties=Get-Cluster $cluster|select drsenabled,haenabled,HAAdmissionControlEnabled|ConvertTo-Html -Property drsenabled,haenabled,HAAdmissionControlEnabled -Fragment -PreContent '<h2>CLUSTERPROPERTIES<h2>'|Out-String

 

 

$datastore_cluster=Get-DatastoreCluster -Location(Get-Datacenter -Cluster $cluster)|select name|ConvertTo-Html -Property name -Fragment -PreContent '<h2>DATASTORECLUSTER<h2>'|Out-String

}

ConvertTo-HTML -head $head -PostContent $clu,$ds,$snap,$powered_off,$vmkernel_vmotion,$windows_vm_tooldsupgrde_needed,$ntp,$version,$cluster_properties,$datastore_cluster,$syslog_server|

Out-String | Out-File -FilePath "$path\test_11feb.html"


Viewing all articles
Browse latest Browse all 49146

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>