Public/Get-AuditReport.ps1

<#PSScriptInfo

.VERSION 1.0

.GUID 972a6d04-f905-4347-98b1-6bf00d8ce204

.AUTHOR dmcanady

.COMPANYNAME

.COPYRIGHT

.TAGS

.LICENSEURI

.PROJECTURI

.ICONURI

.EXTERNALMODULEDEPENDENCIES

.REQUIREDSCRIPTS

.EXTERNALSCRIPTDEPENDENCIES

.RELEASENOTES


.PRIVATEDATA

#>

function Get-AuditReport {
    param (
        [string]$ReportSelection
    )

    $unscannedMSG = "*************************************************************`nThe following were on the audit and were NOT accounted for: `n*************************************************************"
    $unexpectedMSG = "`n************************************************************`nThe following were not on the audit and were accounted for: `n************************************************************"
    $scannedMSG = "`n********************************************************`nThe following were on the audit and were accounted for: `n********************************************************"
    
    if ($ReportSelection -eq "Storage")
    {
        $unscanned = Get-Computers | Where-object {$_.AuditStatus -eq "NotScanned"} | Format-Table AuditStatus, display_name -HideTableHeaders | Out-String
        $unexpected = Get-Computers | Where-object {$_.AuditStatus -eq "Unexpected"} | Format-Table AuditStatus, serial_number -HideTableHeaders | Out-String
        $scanned = Get-Computers |  Where-object {$_.AuditStatus -eq "Scanned"} | Format-Table AuditStatus, serial_number -HideTableHeaders | Out-String
    }
    elseif (($ReportSelection -eq "Repair") -or ($ReportSelection -eq "Assignment"))
    {
        $unscanned = Get-Computers | Where-object {$_.AuditStatus -eq "NotScanned"} | Format-Table AuditStatus, number -HideTableHeaders | Out-String
        $unexpected = Get-Computers | Where-object {$_.AuditStatus -eq "Unexpected"} | Format-Table AuditStatus, cat_item, number -HideTableHeaders | Out-String
        $scanned = Get-Computers |  Where-object {$_.AuditStatus -eq "Scanned"} | Format-Table AuditStatus, number -HideTableHeaders | Out-String
    }

    #format computers hashtable as string
    $script:AuditReport = ($unscannedMSG + $unscanned + $unexpectedMSG + $unexpected + $scannedMSG + $scanned)
    
    Clear-Host
    Write-host $script:AuditReport

    return $script:AuditReport #returns final string
}