{"id":4435,"date":"2015-07-03T13:58:00","date_gmt":"2015-07-03T17:58:00","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=4435"},"modified":"2015-07-03T13:58:00","modified_gmt":"2015-07-03T17:58:00","slug":"sql-database-report-revised","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/","title":{"rendered":"SQL Database Report Revised"},"content":{"rendered":"<p>Last year I wrote an article that explained how to use the SQLSERVER PSDrive to create an HTML report highlighting some server and database information. If you want a refresher you can find that article <a href=\"http:\/\/jdhitsolutions.com\/blog\/powershell\/3900\/sql-database-reports-with-powershell\/\" target=\"_blank\">here<\/a>. In short, you can install the SQL Server PowerShell module on your client desktop and use it to manage remote servers.<br \/>\nDuring a PowerShell class I was teaching this week, I included some content on the SQL cmdlets and had an opportunity to revisit the original script. Even though the original version was intended to work with remote servers, I had a few bugs that prevented that from happening. I also decided to include some additional information as well as incorporate more conditional formatting. For example, depending on how much free space is left, the report might format the value in yellow, to indicate a warning or in red to indicate something more critical.<\/p>\n<p>In the SQLSERVER PSdrive, the Databases directory doesn't show any system databasese by default unless you use -Force.<br \/>\n<a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/sqldatabases.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/sqldatabases-300x160.png\" alt=\"sqldatabases\" width=\"300\" height=\"160\" class=\"aligncenter size-medium wp-image-4436\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/sqldatabases-300x160.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/sqldatabases.png 831w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nSo I updated the script to allow you to include those databases if you want.<\/p>\n<p>Here is the revised script:<\/p>\n<pre class=\"lang:ps decode:true \" >#requires -version 4.0\r\n#requires -module SQLPS\r\n\r\n\r\n&lt;#\r\nCreate a SQL Server database report\r\nThis script includes a graphic file which by default should be in the\r\nsame directory as this script. Otherwise, edit the $ImageFile variable. \r\n\r\nIt is recommended that you import the SQLPS module first and then run \r\nthis script.\r\n\r\nUsage:\r\nc:\\scripts\\SQLServerReport -computername CHI-SQL01 -includesystem -path c:\\work\\CHI-SQL01-DB.htm\r\n\r\n\r\n#&gt;\r\n\r\n[cmdletbinding()]\r\n\r\nParam(\r\n[Parameter(Position=0,HelpMessage=\"Enter the name of a SQL server\")]\r\n[ValidateNotNullorEmpty()]\r\n[Alias(\"CN\")]\r\n[string]$computername=$env:computername,\r\n[Parameter(Position=1,HelpMessage=\"Enter the named instance such as Default\")]\r\n[ValidateNotNullorEmpty()]\r\n[string]$Instance = \"Default\",\r\n[switch]$IncludeSystem,\r\n[ValidateNotNullorEmpty()]\r\n[string]$Path=\"$env:temp\\sqlrpt.htm\",\r\n[switch]$ShowReport\r\n)\r\n\r\n\r\n$scriptversion = \"2.0\"\r\n\r\nWrite-Verbose \"Starting $($MyInvocation.Mycommand)\"\r\n\r\n#define the path to the graphic\r\n$graphic = \"db.png\"\r\n#the default location is the same directory as this script\r\n$imagefile = Join-path -path (split-path $MyInvocation.InvocationName) -ChildPath $graphic\r\n\r\n#define an empty array to hold all of the HTML fragments\r\n$fragments=@(\"&lt;br&gt;&lt;br&gt;&lt;br&gt;\")\r\n\r\n#get uptime\r\nWrite-Verbose \"Getting SQL Server uptime\"\r\nTry {\r\n    #try to connect to the SQL server\r\n    $starttime = Invoke-Sqlcmd -Query 'SELECT sqlserver_start_time AS StartTime FROM sys.dm_os_sys_info' -ServerInstance $computername -database master -ErrorAction Stop\r\n}\r\nCatch {\r\n    Write-warning \"Can't connect to $computername. $($_.exception.message)\"\r\n    #bail out\r\n    Return\r\n}\r\n\r\nWrite-Verbose \"Getting SQL Version\" \r\n$version = Invoke-Sqlcmd \"Select @@version AS Version,@@ServerName AS Name\" -ServerInstance $computername\r\n\r\n#create an object\r\n$uptime = New-Object -TypeName PSObject -Property @{\r\n StartTime = $starttime.Item(0)\r\n Uptime = (Get-Date)-$starttime.Item(0)\r\n Version = $version.Item(0).replace(\"`n\",\"|\")\r\n}\r\n\r\n$tmp = $uptime | ConvertTo-HTML -fragment -AS List\r\n#replace \"|\" place holder with &lt;br&gt;\"\r\n$fragments += $tmp.replace(\"|\",\"&lt;br&gt;\")\r\n\r\n#get services\r\nWrite-Verbose \"Querying SQL services\"\r\n$services = Get-Service -DisplayName *SQL* -ComputerName $computername | \r\nSelect Name,Displayname,Status\r\n\r\n#add conditional formatting to display stopped services in yellow\r\n[xml]$html = $services | ConvertTo-Html -fragment\r\n\r\n#check each row, skipping the TH header row\r\nfor ($i=1;$i -le $html.table.tr.count-1;$i++) {\r\n  $class = $html.CreateAttribute(\"class\")\r\n  #check the value of the last column and assign a class to the row\r\n  if ($html.table.tr[$i].td[-1] -ne 'Running') {                                          \r\n    $html.table.tr[$i].lastChild.setAttribute(\"class\",\"warn\") | Out-Null\r\n  }  \r\n} #for\r\n\r\n\r\n$fragments += \"&lt;h3&gt;SQL Services&lt;\/h3&gt;\"\r\n$fragments += $html.InnerXML\r\n\r\n#get database information\r\n#path to databases\r\n$dbpath = \"SQLServer:\\SQL\\$computername\\$instance\\databases\"\r\nWrite-Verbose \"Querying database information from $dbpath\"\r\n\r\nif ($IncludeSystem) {\r\n    Write-Verbose \"Including system databases\"\r\n    $dbs = Get-ChildItem -path $dbpath -Force\r\n} else {\r\n    $dbs = Get-ChildItem -path $dbpath\r\n}\r\n\r\n[xml]$html = $dbs | Select Name,\r\n@{Name=\"SizeMB\";Expression={$_.size}},\r\n@{Name=\"DataSpaceMB\";Expression={$_.DataSpaceUsage}},\r\n@{Name=\"AvailableMB\";Expression={$_.SpaceAvailable}},\r\n@{Name=\"PercentFree\";Expression={ [math]::Round((($_.SpaceAvailable\/1kb)\/$_.size)*100,2) }} | \r\nSort PercentFree | ConvertTo-HTML -fragment\r\n\r\nfor ($i=1;$i -le $html.table.tr.count-1;$i++) {\r\n  $class = $html.CreateAttribute(\"class\")\r\n  #check the value of the last column and assign a class to the row\r\n  if (($html.table.tr[$i].td[-1] -as [double]) -le 15) {                                          \r\n    $html.table.tr[$i].lastChild.SetAttribute(\"class\",\"danger\") | Out-Null\r\n  }\r\n  elseif (($html.table.tr[$i].td[-1] -as [double]) -le 25) {                                               \r\n    $class.value = \"warn\"    \r\n    $html.table.tr[$i].lastChild.SetAttribute(\"class\",\"warn\") | Out-Null\r\n  }\r\n}\r\n$fragments += \"&lt;h3&gt;Database Utilization&lt;\/h3&gt;\"\r\n$fragments += $html.InnerXml\r\n\r\n$fragments += \"&lt;h3&gt;Database Backup&lt;\/h3&gt;\"\r\n$fragments += $dbs | Select Name,Owner,CreateDate,Last*,RecoveryModel | ConvertTo-Html -Fragment\r\n\r\n#volume usage\r\nWrite-Verbose \"Querying system volumes\"\r\n$data = Get-CimInstance win32_volume -filter \"drivetype=3\" -ComputerName $computername\r\n\r\n$drives = foreach ($item in $data) {\r\n    $prophash = [ordered]@{\r\n    Drive = $item.DriveLetter\r\n    Volume = $item.DeviceID\r\n    Compressed = $item.Compressed\r\n    SizeGB = $item.capacity\/1GB -as [int]\r\n    FreeGB = \"{0:N4}\" -f ($item.Freespace\/1GB )\r\n    PercentFree = [math]::Round((($item.Freespace\/$item.capacity) * 100),2)\r\n    }\r\n\r\n    #create a new object from the property hash\r\n    New-Object PSObject -Property $prophash\r\n}\r\n\r\n[xml]$html = $drives | ConvertTo-Html -fragment\r\n\r\n#check each row, skipping the TH header row\r\nfor ($i=1;$i -le $html.table.tr.count-1;$i++) {\r\n  $class = $html.CreateAttribute(\"class\")\r\n  #check the value of the last column and assign a class to the row\r\n  if (($html.table.tr[$i].td[-1] -as [int]) -le 25) {                                          \r\n    $html.table.tr[$i].lastChild.SetAttribute(\"class\",\"danger\") | Out-Null\r\n  }\r\n  elseif (($html.table.tr[$i].td[-1] -as [int]) -le 35) {                                               \r\n    $class.value = \"warn\"    \r\n    $html.table.tr[$i].lastChild.SetAttribute(\"class\",\"warn\") | Out-Null\r\n  }\r\n}\r\n\r\n$fragments += \"&lt;h3&gt;Volume Utilization&lt;\/h3&gt;\"\r\n$fragments += $html.innerxml\r\n\r\n#define the HTML style\r\nWrite-Verbose \"preparing report\"\r\n\r\n#encode the graphic file to embed into the HTML\r\n$ImageBits = [Convert]::ToBase64String((Get-Content $imagefile -Encoding Byte))\r\n$ImageHTML = \"&lt;img src=data:image\/png;base64,$($ImageBits) alt='db utilization'\/&gt;\"\r\n\r\n#define a here string for the html header\r\n$head = @\"\r\n&lt;style&gt;\r\nbody { background-color:#FAFAFA;\r\n       font-family:Arial;\r\n       font-size:12pt; }\r\ntd, th { border:1px solid black; \r\n         border-collapse:collapse; }\r\nth { color:white;\r\n     background-color:black; }\r\ntable, tr, td, th { padding: 2px; margin: 0px }\r\ntr:nth-child(odd) {background-color: lightgray}\r\ntable { margin-left:50px; }\r\nimg\r\n{\r\nfloat:left;\r\nmargin: 0px 25px;\r\n}\r\n.danger {background-color: red}\r\n.warn {background-color: yellow}\r\n&lt;\/style&gt;\r\n$imagehtml\r\n&lt;br&gt;&lt;br&gt;&lt;br&gt;\r\n&lt;H2&gt;SQL Server Report: $($version.name)&lt;\/H2&gt;\r\n&lt;br&gt;\r\n\"@\r\n\r\n#HTML to display at the end of the report\r\n$footer = @\"\r\n&lt;br&gt;\r\n&lt;i&gt;\r\nDate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;: $(Get-Date)&lt;br&gt;\r\nAuthor&amp;nbsp;: $env:USERDOMAIN\\$env:username&lt;br&gt;\r\nVersion: $scriptVersion&lt;br&gt;\r\n&lt;\/i&gt;\r\n\"@\r\n\r\n#create the HTML document\r\nConvertTo-HTML -Head $head -Body $fragments -PostContent $footer |\r\nOut-File -FilePath $path -Encoding ascii\r\n\r\nif ($ShowReport) {\r\n    #open the finished report\r\n    Write-Verbose \"Opening report $path\"\r\n    Invoke-Item $path\r\n}\r\n\r\nWrite-Verbose \"Ending $($MyInvocation.Mycommand)\"<\/pre>\n<p>My script includes a graphic file to make it pretty. You can download my graphic file<a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/db.png\" target=\"_blank\" title=\"right click and save as\"> db.png<\/a>.  Put the graphic in the same directory as the script. Or modify the script to use your own graphics. You can then run a command like this to generate the HTML report.<\/p>\n<pre class=\"lang:ps decode:true \" >c:\\scripts\\sqlserverreport.ps1 -computername chi-sql01 -IncludeSystem -path s:\\chi-sql01.htm -verbose\r\n<\/pre>\n<p>This script lacks a provision for alternate credentials and assumes the account you are running under has the necessary SQL permissions. When finished you can get a report like <a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/chi-sql01.htm\" target=\"_blank\" title=\"view a sample report\">this<\/a>.<\/p>\n<p>I hope you'll let me know what you think and if you find this useful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last year I wrote an article that explained how to use the SQLSERVER PSDrive to create an HTML report highlighting some server and database information. If you want a refresher you can find that article here. In short, you can install the SQL Server PowerShell module on your client desktop and use it to manage&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New Blog Post: #PowerShell SQL Database Report Revised","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,8,431],"tags":[237,534,540,577],"class_list":["post-4435","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","category-sql-server","tag-html","tag-powershell","tag-scripting","tag-sql-server"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Database Report Revised &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Database Report Revised &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Last year I wrote an article that explained how to use the SQLSERVER PSDrive to create an HTML report highlighting some server and database information. If you want a refresher you can find that article here. In short, you can install the SQL Server PowerShell module on your client desktop and use it to manage...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2015-07-03T17:58:00+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/sqldatabases-300x160.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4435\\\/sql-database-report-revised\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4435\\\/sql-database-report-revised\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"SQL Database Report Revised\",\"datePublished\":\"2015-07-03T17:58:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4435\\\/sql-database-report-revised\\\/\"},\"wordCount\":289,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4435\\\/sql-database-report-revised\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/sqldatabases-300x160.png\",\"keywords\":[\"HTML\",\"PowerShell\",\"Scripting\",\"SQL Server\"],\"articleSection\":[\"PowerShell\",\"Scripting\",\"SQL Server\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4435\\\/sql-database-report-revised\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4435\\\/sql-database-report-revised\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4435\\\/sql-database-report-revised\\\/\",\"name\":\"SQL Database Report Revised &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4435\\\/sql-database-report-revised\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4435\\\/sql-database-report-revised\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/sqldatabases-300x160.png\",\"datePublished\":\"2015-07-03T17:58:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4435\\\/sql-database-report-revised\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4435\\\/sql-database-report-revised\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4435\\\/sql-database-report-revised\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/sqldatabases.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/sqldatabases.png\",\"width\":831,\"height\":442},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4435\\\/sql-database-report-revised\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Database Report Revised\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Database Report Revised &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/","og_locale":"en_US","og_type":"article","og_title":"SQL Database Report Revised &#8226; The Lonely Administrator","og_description":"Last year I wrote an article that explained how to use the SQLSERVER PSDrive to create an HTML report highlighting some server and database information. If you want a refresher you can find that article here. In short, you can install the SQL Server PowerShell module on your client desktop and use it to manage...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/","og_site_name":"The Lonely Administrator","article_published_time":"2015-07-03T17:58:00+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/sqldatabases-300x160.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"SQL Database Report Revised","datePublished":"2015-07-03T17:58:00+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/"},"wordCount":289,"commentCount":3,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/sqldatabases-300x160.png","keywords":["HTML","PowerShell","Scripting","SQL Server"],"articleSection":["PowerShell","Scripting","SQL Server"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/","name":"SQL Database Report Revised &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/sqldatabases-300x160.png","datePublished":"2015-07-03T17:58:00+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/sqldatabases.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/07\/sqldatabases.png","width":831,"height":442},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4435\/sql-database-report-revised\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"SQL Database Report Revised"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":3900,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3900\/sql-database-reports-with-powershell\/","url_meta":{"origin":4435,"position":0},"title":"SQL Database Reports with PowerShell","author":"Jeffery Hicks","date":"July 2, 2014","format":false,"excerpt":"Last year I wrote an article for SQL Server Pro called PowerShell in SQL Server. In the article I provided an introduction to using PowerShell and the SQL Server module to do perform some typical management tasks. I think this type of information is especially important for those of you\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"talkbubble","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":5675,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5675\/powershell-reminders-now-in-beta\/","url_meta":{"origin":4435,"position":1},"title":"PowerShell Reminders now in Beta","author":"Jeffery Hicks","date":"October 6, 2017","format":false,"excerpt":"For awhile now I've been working on a PowerShell project that I use every day. I am always in a PowerShell prompt and because I always seem to have little things like phone calls or family events that I need to keep track of, I wrote a \"tickler\" system. The\u2026","rel":"","context":"In &quot;GitHub&quot;","block_context":{"text":"GitHub","link":"https:\/\/jdhitsolutions.com\/blog\/category\/github\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/10\/image_thumb.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/10\/image_thumb.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/10\/image_thumb.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/10\/image_thumb.png?resize=700%2C400 2x"},"classes":[]},{"id":3361,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3361\/creating-styling-html-reports-with-powershell\/","url_meta":{"origin":4435,"position":2},"title":"Creating Styling HTML Reports with PowerShell","author":"Jeffery Hicks","date":"August 26, 2013","format":false,"excerpt":"Last month I did an updated version of my presentation on creating styling HTML reports in Windows PowerShell. This presentation was for the PowerShell virtual chapter of SQL PASS. As such, I came up with some SQL related demonstrations and fine tuned some demos from earlier presentations. You can download\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1801,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1801\/finding-files-in-the-path-a-pipeline-perk\/","url_meta":{"origin":4435,"position":3},"title":"Finding Files in the Path &#8211; A Pipeline Perk","author":"Jeffery Hicks","date":"November 17, 2011","format":false,"excerpt":"I've been chipping in on a forum post about finding if a given file exists in any folder within the system environmental %PATH% variable using Windows PowerShell. There are several ways you might approach this. But the best way in my opinion is to leverage the PowerShell pipeline. Perhaps you\u2026","rel":"","context":"In &quot;Scripting&quot;","block_context":{"text":"Scripting","link":"https:\/\/jdhitsolutions.com\/blog\/category\/scripting\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":9422,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9422\/introducing-psreminderlite\/","url_meta":{"origin":4435,"position":4},"title":"Introducing PSReminderLite","author":"Jeffery Hicks","date":"August 14, 2024","format":false,"excerpt":"For several years, I have been using a PowerShell module I wrote called MyTickle to help me manage my reminders and events. I spend my days at a PowerShell prompt, and I wanted an easy way to keep track of upcoming events. The module relied on a SQL Server or\u2026","rel":"","context":"In &quot;GitHub&quot;","block_context":{"text":"GitHub","link":"https:\/\/jdhitsolutions.com\/blog\/category\/github\/"},"img":{"alt_text":"PSReminderTags","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2024\/08\/remindertags-300x148.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2817,"url":"https:\/\/jdhitsolutions.com\/blog\/prof-powershell\/2817\/on-the-road\/","url_meta":{"origin":4435,"position":5},"title":"On the Road","author":"Jeffery Hicks","date":"February 26, 2013","format":false,"excerpt":"After a long winter I think is time for a road trip. I will out and about over the next few months, hopefully speaking at an event near you. Many of the events are free or charge a small fee, but all I hope will be worth your time. These\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"map","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/07\/map-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4435","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=4435"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4435\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}