Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 168455

Re: vCenter licenses deatils

$
0
0

How about an html report?

The CSS/HTML part of this code is inspired from http://hostilecoding.blogspot.no/2014/03/vmware-fancy-html-reports-using-powercli.html

 

$PathToSaveTheReport = "C:\temp\Report.html"

$vCenterName = "testvCenter"

Connect-VIServer -Server $vCenterName

$ServiceInstance = Get-View ServiceInstance

$LicenseManager = Get-View $ServiceInstance.Content.LicenseManager

$licenseAssignmentManager = Get-View $LicenseManager.licenseAssignmentManager

 

#Get VC license Information

$vCenterInformation= $LicenseManager.licenses | select @{Name="vCenter";Expression={$vCenterName}},Name,LicenseKey,Used,Total | ConvertTo-HTML -Fragment

 

#Get Host license Information

$HostInformation = Get-View -ViewType HostSystem | foreach-object{

$AssignedLicense = ($licenseAssignmentManager.QueryAssignedLicenses($_.Moref.Value)).AssignedLicense

            $Output = New-Object -Type PSObject -Prop ([ordered]@{

            'vCenterName' = $vCenterName

            'Hostname' = $_.Name

            'version' = $_.Config.Product.Version

            'MemorySize' = $_.Hardware.MemorySize

            'core_num' =$_.Hardware.CpuInfo.NumCpuCores

            'cpu_num' =$_.Hardware.cpuinfo.Numcpupackages

            'Boottime' = $_.Summary.Runtime.BootTime

            'licenseKey' = $AssignedLicense.LicenseKey

            'Name' = $AssignedLicense.name

            })         

            Return $Output

}| ConvertTo-HTML -Fragment

 

 

#This is the CSS used to add the style to the report

 

$Css="<style>

body {

    font-family: Verdana, sans-serif;

    font-size: 14px;

    color: #666666;

    background: #FEFEFE;

}

#title{

    color:#90B800;

    font-size: 30px;

    font-weight: bold;

    padding-top:25px;

    margin-left:35px;

    height: 50px;

}

#subtitle{

    font-size: 11px;

    margin-left:35px;

}

#main {

    position:relative;

    padding-top:10px;

    padding-left:10px;

    padding-bottom:10px;

    padding-right:10px;

}

#box1{

    position:absolute;

    background: #F8F8F8;

    border: 1px solid #DCDCDC;

    margin-left:10px;

    padding-top:10px;

    padding-left:10px;

    padding-bottom:10px;

    padding-right:10px;

}

#boxheader{

    font-family: Arial, sans-serif;

    padding: 5px 20px;

    position: relative;

    z-index: 20;

    display: block;

    height: 30px;

    color: #777;

    text-shadow: 1px 1px 1px rgba(255,255,255,0.8);

    line-height: 33px;

    font-size: 19px;

    background: #fff;

    background: -moz-linear-gradient(top, #ffffff 1%, #eaeaea 100%);

    background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#ffffff), color-stop(100%,#eaeaea));

    background: -webkit-linear-gradient(top, #ffffff 1%,#eaeaea 100%);

    background: -o-linear-gradient(top, #ffffff 1%,#eaeaea 100%);

    background: -ms-linear-gradient(top, #ffffff 1%,#eaeaea 100%);

    background: linear-gradient(top, #ffffff 1%,#eaeaea 100%);

    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eaeaea',GradientType=0 );

    box-shadow:

        0px 0px 0px 1px rgba(155,155,155,0.3),

        1px 0px 0px 0px rgba(255,255,255,0.9) inset,

        0px 2px 2px rgba(0,0,0,0.1);

}

table{

    width:100%;

    border-collapse:collapse;

}

table td, table th {

    border:1px solid #98bf21;

    padding:3px 7px 2px 7px;

}

table th {

    text-align:left;

    padding-top:5px;

    padding-bottom:4px;

    background-color:#90B800;

color:#fff;

}

table tr.alt td {

    color:#000;

    background-color:#EAF2D3;

}

</style>"

 

#These are divs declarations used to properly style HTML using previously defined CSS

 

$PageBoxOpener="<div id='box1'>"

$ReportVClicense="<div id='boxheader'>vcenter license</div>"

$BoxContentOpener="<div id='boxcontent'>"

$PageBoxCloser="</div>"

$br="<br>" #This should have been defined in CSS but if you need new line you could also use it this way

$ReportEsxiLicense="<div id='boxheader'>ESXi license</div>"

 

 

#Create HTML report

#-Head parameter could be omitted if header is declared in body

ConvertTo-Html -Title "Test Title" -Head "<div id='title'>PowerCLI Reporting</div>$br<div id='subtitle'>Report generated: $(Get-Date)</div>" -Body " $Css $PageBoxOpener $ReportVClicense $BoxContentOpener $vCenterInformation $PageBoxCloser $br $ReportEsxiLicense $BoxContentOpener $HostInformation $PageBoxCloser"  | Out-File $PathToSaveTheReport


Viewing all articles
Browse latest Browse all 168455

Trending Articles



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