Added sbom powershell script

This commit is contained in:
tke
2023-02-09 13:33:24 +01:00
parent 8ee789a984
commit 225cfc2fab

48
codegrab/sbom.ps1 Normal file
View File

@@ -0,0 +1,48 @@
# Get a list of all installed software from the Windows software library
$installedSoftware = Get-Package
# Get a list of all installed Windows updates
$installedUpdates = Get-HotFix
# Get a list of all Chocolatey packages
$chocoPackages = choco list --localonly
# Create a variable to hold all of the information
$sbom = @()
# Add the installed software to the SBOM
$sbom += $installedSoftware
# Add the formatted updates to the SBOM
$sbom += $installedUpdates
# Add the Chocolatey packages to the SBOM
$sbom += $chocoPackages
# Get the folder path
$folderPath = "C:\Forensic Program Files"
# Get all EXE files in the folder and its subfolders
$exeFiles = Get-ChildItem $folderPath -Recurse -Filter "*.exe"
# Create a variable to hold the EXE file information
$exeInfo = @()
# Loop through each EXE file
foreach ($exeFile in $exeFiles) {
# Get the file version information
$fileVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($exeFile.FullName)
# Add the EXE file information to the array
$exeInfo += New-Object PSObject -Property @{
"Path" = $exeFile.FullName
"Product Name" = $fileVersion.ProductName
"Product Version" = $fileVersion.ProductVersion
}
}
# Add the EXE file information to the SBOM
$sbom += $exeInfo
# Export the SBOM to a CSV file
$sbom | Export-Csv C:\tmp\sbom.csv -NoTypeInformation