Functions/Public/Start-COVSoftwareSearch.ps1

<#
.SYNOPSIS
Start-COVSoftwareSearch is used to query all installed software on a remote computer
.PARAMETER ComputerName
Mandatory parameter that defines the machine the query will be ran on
.PARAMETER ExportToCsv
Switch parameter used to give the user the option to export the results to a CSV file. The output will default to Out-Gridview if
this parameter is not specified
     
.EXAMPLE
    Start-CovSoftwareSearch -Computername INT012055T
    Retrieves all installed software on INT012055T
    Start-CovSoftwareSearch -Computername INT012055T
    Retrieves all installed software on INT012055T and then exports the results to a CSV file
 
#>

function Start-COVSoftwareSearch {
    
    [CmdletBinding(SupportsShouldProcess)]    
    param(
        [Parameter(Mandatory,ValueFromPipelineByPropertyName,ValueFromPipeline)]
        [String]
        $Identity
        

    )

    $Props = 'Displayname',
             'DisplayVersion',
              @{Name = 'Vendor';Expression = { $_.Publisher }}


    Write-Verbose "Reaching out to remote computer"
    Write-Verbose "Retrieving software list...."
    Write-Verbose "Script has finished successfully"

    Write-Output $Identity

        
        
    Invoke-Command -ComputerName $Identity {
        
        $Apps = @()
        $Apps += Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" # 32 Bit
        $Apps += Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"             # 64 Bit
                
        $Apps | Sort-Object Displayname 
                
    } | Select-Object -Property $Props
        
        
        

        
}