From 4d17cae49a07f3de6b1b4d5804db52f412fc0689 Mon Sep 17 00:00:00 2001 From: Jonathan Colon Date: Tue, 25 Jun 2024 12:43:07 -0400 Subject: [PATCH] Minor code changes --- Src/Private/Get-AbrWinApplication.ps1 | 4 +- .../Get-AbrWinFOClusterSharedVolume.ps1 | 8 ++-- Src/Private/Get-AbrWinHostStorageVolume.ps1 | 18 ++++--- Src/Private/Get-AbrWinIISWebSite.ps1 | 48 ++++++++----------- Src/Private/Get-AbrWinOSHotfix.ps1 | 8 ++-- Src/Private/Get-RequiredFeature.ps1 | 5 +- 6 files changed, 41 insertions(+), 50 deletions(-) diff --git a/Src/Private/Get-AbrWinApplication.ps1 b/Src/Private/Get-AbrWinApplication.ps1 index ff8f65a..3b7e930 100644 --- a/Src/Private/Get-AbrWinApplication.ps1 +++ b/Src/Private/Get-AbrWinApplication.ps1 @@ -5,7 +5,7 @@ function Get-AbrWinApplication { .DESCRIPTION Documents the configuration of Microsoft Windows Server in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.5.4 + Version: 0.5.5 Author: Andrew Ramsay Editor: Jonathan Colon Twitter: @asbuiltreport @@ -47,7 +47,7 @@ function Get-AbrWinApplication { } 'Install Date' = Switch ([string]::IsNullOrEmpty($App.InstallDate)) { $true { "--" } - $false {$App.InstallDate} + $false { $App.InstallDate } default { 'Unknown' } } } diff --git a/Src/Private/Get-AbrWinFOClusterSharedVolume.ps1 b/Src/Private/Get-AbrWinFOClusterSharedVolume.ps1 index 890c6fa..0849270 100644 --- a/Src/Private/Get-AbrWinFOClusterSharedVolume.ps1 +++ b/Src/Private/Get-AbrWinFOClusterSharedVolume.ps1 @@ -5,7 +5,7 @@ function Get-AbrWinFOClusterSharedVolume { .DESCRIPTION Documents the configuration of Microsoft Windows Server in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.5.2 + Version: 0.5.5 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux @@ -36,9 +36,9 @@ function Get-AbrWinFOClusterSharedVolume { 'Name' = $Setting.Name 'Owner Node' = $Setting.OwnerNode 'Shared Volume' = Switch ([string]::IsNullOrEmpty($Setting.SharedVolumeInfo.FriendlyVolumeName)) { - $true {"Unknown"} - $false {$Setting.SharedVolumeInfo.FriendlyVolumeName} - default {"--"} + $true { "Unknown" } + $false { $Setting.SharedVolumeInfo.FriendlyVolumeName } + default { "--" } } 'State' = $Setting.State } diff --git a/Src/Private/Get-AbrWinHostStorageVolume.ps1 b/Src/Private/Get-AbrWinHostStorageVolume.ps1 index c5ddc74..9398b50 100644 --- a/Src/Private/Get-AbrWinHostStorageVolume.ps1 +++ b/Src/Private/Get-AbrWinHostStorageVolume.ps1 @@ -5,7 +5,7 @@ function Get-AbrWinHostStorageVolume { .DESCRIPTION Documents the configuration of Microsoft Windows Server in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.5.2 + Version: 0.5.5 Author: Andrew Ramsay Editor: Jonathan Colon Twitter: @asbuiltreport @@ -21,17 +21,17 @@ function Get-AbrWinHostStorageVolume { begin { Write-PScriboMessage "Storage InfoLevel set at $($InfoLevel.Storage)." - Write-PscriboMessage "Collecting Host Storage Volume information." + Write-PScriboMessage "Collecting Host Storage Volume information." } process { if ($InfoLevel.Storage -ge 1) { try { - $HostVolumes = Invoke-Command -Session $TempPssSession -ScriptBlock { Get-Volume | Where-Object {$_.DriveType -ne "CD-ROM" -and $_.DriveLetter} } + $HostVolumes = Invoke-Command -Session $TempPssSession -ScriptBlock { Get-Volume | Where-Object { $_.DriveType -ne "CD-ROM" -and $_.DriveLetter } } if ($HostVolumes) { Section -Style Heading3 'Host Volumes' { Paragraph 'The following section details local volumes on the host' - Blankline + BlankLine $HostVolumeReport = @() ForEach ($HostVolume in $HostVolumes) { try { @@ -44,9 +44,8 @@ function Get-AbrWinHostStorageVolume { 'Health Status' = $HostVolume.HealthStatus } $HostVolumeReport += $TempHostVolumeReport - } - catch { - Write-PscriboMessage -IsWarning $_.Exception.Message + } catch { + Write-PScriboMessage -IsWarning $_.Exception.Message } } $TableParams = @{ @@ -60,9 +59,8 @@ function Get-AbrWinHostStorageVolume { $HostVolumeReport | Sort-Object -Property 'Drive Letter' | Table @TableParams } } - } - catch { - Write-PscriboMessage -IsWarning $_.Exception.Message + } catch { + Write-PScriboMessage -IsWarning $_.Exception.Message } } } diff --git a/Src/Private/Get-AbrWinIISWebSite.ps1 b/Src/Private/Get-AbrWinIISWebSite.ps1 index 763470e..f02ccd0 100644 --- a/Src/Private/Get-AbrWinIISWebSite.ps1 +++ b/Src/Private/Get-AbrWinIISWebSite.ps1 @@ -5,7 +5,7 @@ function Get-AbrWinIISWebSite { .DESCRIPTION Documents the configuration of Microsoft Windows Server in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.5.2 + Version: 0.5.5 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux @@ -20,7 +20,7 @@ function Get-AbrWinIISWebSite { begin { Write-PScriboMessage "IIS InfoLevel set at $($InfoLevel.IIS)." - Write-PscriboMessage "Collecting IIS Sites information." + Write-PScriboMessage "Collecting IIS Sites information." } process { @@ -30,7 +30,7 @@ function Get-AbrWinIISWebSite { if ($IISWebSites) { Section -Style Heading3 'Sites Summary' { Paragraph 'The following table provide a summary of IIS Web Sites' - Blankline + BlankLine $IISWebSitesrReport = @() foreach ($IISWebSite in $IISWebSites) { try { @@ -41,9 +41,8 @@ function Get-AbrWinIISWebSite { 'Application Pool' = $IISWebSite.applicationPool } $IISWebSitesrReport += $TempIISWebSitesrReport - } - catch { - Write-PscriboMessage -IsWarning $_.Exception.Message + } catch { + Write-PScriboMessage -IsWarning $_.Exception.Message } } @@ -61,21 +60,21 @@ function Get-AbrWinIISWebSite { if ($IISWebSites) { Section -Style Heading4 'Sites Configuration' { Paragraph 'The following section details IIS Web Sites configuration' - Blankline + BlankLine $IISWebSitesrReport = @() foreach ($IISWebSite in $IISWebSites) { try { Section -Style Heading5 "$($IISWebSite.Name)" { Paragraph "The following table details $($IISWebSite.Name) settings" - Blankline - $SiteURL = Invoke-Command -Session $TempPssSession { Get-WebURL -PSPath "IIS:\Sites\$(($using:IISWebSite).Name)"} + BlankLine + $SiteURL = Invoke-Command -Session $TempPssSession { Get-WebURL -PSPath "IIS:\Sites\$(($using:IISWebSite).Name)" } $TempIISWebSitesrReport = [PSCustomObject]@{ 'Name' = $IISWebSite.Name 'Auto Start' = ConvertTo-TextYN $IISWebSite.serverAutoStart 'Enabled Protocols ' = $IISWebSite.enabledProtocols 'URL' = Switch (($SiteURL.ResponseUri).count) { - 0 {"--"} - default {$SiteURL.ResponseUri} + 0 { "--" } + default { $SiteURL.ResponseUri } } 'Path ' = $IISWebSite.physicalPath 'Log Path' = $IISWebSite.logFile.directory @@ -97,7 +96,7 @@ function Get-AbrWinIISWebSite { if ($IISWebApps) { Section -Style Heading5 "Web Applications" { Paragraph "The following table details $($IISWebSite.Name) Web Application" - Blankline + BlankLine $IISWebAppsReport = @() foreach ($IISWebApp in $IISWebApps) { try { @@ -107,9 +106,8 @@ function Get-AbrWinIISWebSite { 'Physical Path ' = $IISWebApp.PhysicalPath } $IISWebAppsReport += $TempIISWebAppsReport - } - catch { - Write-PscriboMessage -IsWarning $_.Exception.Message + } catch { + Write-PScriboMessage -IsWarning $_.Exception.Message } } @@ -124,27 +122,23 @@ function Get-AbrWinIISWebSite { $IISWebAppsReport | Table @TableParams } } - } - catch { - Write-PscriboMessage -IsWarning $_.Exception.Message + } catch { + Write-PScriboMessage -IsWarning $_.Exception.Message } } - } - catch { - Write-PscriboMessage -IsWarning $_.Exception.Message + } catch { + Write-PScriboMessage -IsWarning $_.Exception.Message } } } } - } - catch { - Write-PscriboMessage -IsWarning $_.Exception.Message + } catch { + Write-PScriboMessage -IsWarning $_.Exception.Message } } } - } - catch { - Write-PscriboMessage -IsWarning $_.Exception.Message + } catch { + Write-PScriboMessage -IsWarning $_.Exception.Message } } } diff --git a/Src/Private/Get-AbrWinOSHotfix.ps1 b/Src/Private/Get-AbrWinOSHotfix.ps1 index a9ac66c..cbfd85e 100644 --- a/Src/Private/Get-AbrWinOSHotfix.ps1 +++ b/Src/Private/Get-AbrWinOSHotfix.ps1 @@ -5,7 +5,7 @@ function Get-AbrWinOSHotfix { .DESCRIPTION Documents the configuration of Microsoft Windows Server in Word/HTML/Text formats using PScribo. .NOTES - Version: 0.5.2 + Version: 0.5.5 Author: Andrew Ramsay Editor: Jonathan Colon Twitter: @asbuiltreport @@ -37,9 +37,9 @@ function Get-AbrWinOSHotfix { 'Hotfix ID' = $HotFix.HotFixID 'Description' = $HotFix.Description 'Installation Date' = Switch ([string]::IsNullOrEmpty($HotFix.InstalledOn)) { - $true {'--'} - $false {$HotFix.InstalledOn.ToShortDateString()} - default {'Unknown'} + $true { '--' } + $false { $HotFix.InstalledOn.ToShortDateString() } + default { 'Unknown' } } } $HotfixReport += $TempHotFix diff --git a/Src/Private/Get-RequiredFeature.ps1 b/Src/Private/Get-RequiredFeature.ps1 index 94d4029..3f415d0 100644 --- a/Src/Private/Get-RequiredFeature.ps1 +++ b/Src/Private/Get-RequiredFeature.ps1 @@ -5,7 +5,7 @@ function Get-RequiredFeature { .DESCRIPTION Function to check if the required version of windows feature is installed .NOTES - Version: 0.5.2 + Version: 0.5.5 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux @@ -88,8 +88,7 @@ function Get-RequiredFeature { Write-PScriboMessage -IsWarning "$Name module is required to be installed on $System to be able to document $Service service. Run 'Install-WindowsFeature -Name '$($Name)'' to install the required modules." } } - } - else { + } else { throw "Unable to validate if $Name is installed. https://github.com/AsBuiltReport/AsBuiltReport.Microsoft.Windows" } }