$date = Get-Date $rDate = ( Get-Date -format "MM-dd-yyyy" ) $strPath = "C:\Scripts\PS1\serverinfo-$rDate.xlsx" $xl = New-Object -comobject Excel.Application $xl .Visible = $True $xl .DisplayAlerts = $False $wb = $a .Workbooks.Add() $ws = $b .Worksheets.Item(1) $ws .Name = $rDate $ws .Cells.Item(1,1) = "Machine Name" $ws .Cells.Item(1,2) = "FriendlyName" $ws .Cells.Item(1,3) = "NotAfter" $ws .Cells.Item(1,4) = "Issuer" $xRow = 2 $cert = dir IIS:\SslBindings | ? { $_ .Port -eq 443} | Select * foreach ( $i in $cert ) { $x = $i .thumbprint $y = get-item cert:\LocalMachine\My\ $x $FN = $y .FriendlyName $NA = $y .NotAfter $IS = $y .Issuer $ws .Cells.Item( $xRow ,1) = $comp $ws .Cells.Item( $xRow ,2) = $FN $ws .Cells.Item( $xRow ,3) = $NA $ws .Cells.Item( $xRow ,4) = $IS $xRow ++ }