Public/Show-OSBMediaInfo.ps1
<# .SYNOPSIS Shows Operating System information of any OSBuilder Media .DESCRIPTION Shows Operating System information of any OSBuilder Media (OSMedia, OSBuilds, PEBuilds) .LINK https://www.osdeploy.com/osbuilder/docs/functions/media/show-osbmediainfo .PARAMETER FullName Full Path of the OSBuilder Media #> function Show-OSBMediaInfo { [CmdletBinding()] PARAM ( [Parameter(ValueFromPipelineByPropertyName)] [string[]]$FullName ) BEGIN { #Write-Host '========================================================================================' -ForegroundColor DarkGray #Write-Host "$($MyInvocation.MyCommand.Name) BEGIN" -ForegroundColor Green #=================================================================================================== Write-Verbose '19.1.1 Initialize OSBuilder' #=================================================================================================== Get-OSBuilder -CreatePaths -HideDetails #=================================================================================================== Write-Verbose '19.1.1 Gather All OS Media' #=================================================================================================== $AllOSMedia = @() $AllOSMedia = $(Get-OSMedia) $AllOSBuild = @() $AllOSBuild = $(Get-OSBuilds) $AllPEBuild = @() $AllPEBuild = $(Get-PEBuilds) $AllOSBMedia = @() $AllOSBMedia = $AllOSMedia + $AllOSBuild + $AllPEBuild #$AllOSBMedia = $(Get-OSMedia) + $(Get-OSBuilds) + $(Get-PEBuilds) } PROCESS { #Write-Host '========================================================================================' -ForegroundColor DarkGray #Write-Host "$($MyInvocation.MyCommand.Name) PROCESS" -ForegroundColor Green #=================================================================================================== Write-Verbose '19.1.1 Select Source OSMedia' #=================================================================================================== $SelectedOSMedia = @() if ($FullName) { foreach ($Item in $FullName) { Write-Verbose "Checking $Item" $SelectedOSMedia += $AllOSBMedia | Where-Object {$_.FullName -eq $Item} } } else { $SelectedOSMedia = $AllOSBMedia | Out-GridView -Title "OSBuilder: Select one or more Media and press OK (Cancel to Exit)" -PassThru } #=================================================================================================== Write-Verbose '19.1.1 Process OSMedia' #=================================================================================================== foreach ($Media in $SelectedOSMedia) { Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Show-OSBMediaInfo -FullName '$($Media.FullName)'" -ForegroundColor Green if (!(Test-Path $(Join-Path $Media.FullName (Join-Path "info" (Join-Path "json" "Get-WindowsImage.json"))))) { Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Warning "Could not find an OSBuilder Operating System at $Media.FullName" } else { if (!($($Media.FullName) -like "*PEBuilds*")) { #=================================================================================================== Write-Verbose '19.1.1 Enabled Appx Provisioned Packages' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Enabled Appx Provisioned Packages" -ForegroundColor Green $GetAppxProvisionedPackageJson = Join-Path $($Media.FullName) (Join-Path "info" (Join-Path "json" "Get-AppxProvisionedPackage.json")) if ($Media.Name -like "*server*") {Write-Warning "Appx Provisioned Packages are not present in Windows Server"} if (Test-Path $GetAppxProvisionedPackageJson) { $GetAppxProvisionedPackage = Get-Content -Raw -Path $GetAppxProvisionedPackageJson | ConvertFrom-Json foreach ($Item in $GetAppxProvisionedPackage) {Write-Host "$($Item.DisplayName)"} } } #=================================================================================================== Write-Verbose '19.1.1 Windows Packages' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Windows Packages" -ForegroundColor Green $GetWindowsPackageJson = Join-Path $($Media.FullName) (Join-Path "info" (Join-Path "json" "Get-WindowsPackage.json")) if (Test-Path $GetWindowsPackageJson) { $GetWindowsPackage = Get-Content -Raw -Path $GetWindowsPackageJson | ConvertFrom-Json $GetWindowsPackage = $GetWindowsPackage | Where-Object {$_.PackageName -notlike "*Package_for*"} $GetWindowsPackage = $GetWindowsPackage | Where-Object {$_.PackageName -notlike "*LanguageFeatures-Basic*"} foreach ($Item in $GetWindowsPackage) {Write-Host "$($Item.PackageName)"} } if (!($($Media.FullName) -like "*PEBuilds*")) { #=================================================================================================== Write-Verbose '19.1.1 Windows Packages (Language Features Basic)' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Windows Packages (Language Features Basic)" -ForegroundColor Green $GetWindowsPackageJson = Join-Path $($Media.FullName) (Join-Path "info" (Join-Path "json" "Get-WindowsPackage.json")) if (Test-Path $GetWindowsPackageJson) { $GetWindowsPackage = Get-Content -Raw -Path $GetWindowsPackageJson | ConvertFrom-Json $GetWindowsPackage = $GetWindowsPackage | Where-Object {$_.PackageName -like "*LanguageFeatures-Basic*"} foreach ($Item in $GetWindowsPackage) {Write-Host "$($Item.PackageName)"} } #=================================================================================================== Write-Verbose '19.1.1 Windows Capabilities' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Windows Capabilities" -ForegroundColor Green $GetWindowsCapabilityJson = Join-Path $($Media.FullName) (Join-Path "info" (Join-Path "json" "Get-WindowsCapability.json")) if (Test-Path $GetWindowsCapabilityJson) { $GetWindowsCapability = Get-Content -Raw -Path $GetWindowsCapabilityJson | ConvertFrom-Json $GetWindowsCapability = $GetWindowsCapability | Where-Object {$_.Name -notlike "*Language.Basic*"} foreach ($Item in $GetWindowsCapability) {Write-Host "$($Item.Name)"} } #=================================================================================================== Write-Verbose '19.1.1 Windows Capabilities (Language.Basic)' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Windows Capabilities (Language.Basic)" -ForegroundColor Green $GetWindowsCapabilityJson = Join-Path $($Media.FullName) (Join-Path "info" (Join-Path "json" "Get-WindowsCapability.json")) if (Test-Path $GetWindowsCapabilityJson) { $GetWindowsCapability = Get-Content -Raw -Path $GetWindowsCapabilityJson | ConvertFrom-Json $GetWindowsCapability = $GetWindowsCapability | Where-Object {$_.Name -like "*Language.Basic*"} foreach ($Item in $GetWindowsCapability) {Write-Host "$($Item.Name)"} } #=================================================================================================== Write-Verbose '19.1.1 Windows Optional Features (Enabled)' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Windows Optional Features (Enabled)" -ForegroundColor Green $WindowsOptionalFeatureJson = Join-Path $($Media.FullName) (Join-Path "info" (Join-Path "json" "Get-WindowsOptionalFeature.json")) if (Test-Path $WindowsOptionalFeatureJson) { $WindowsOptionalFeature = Get-Content -Raw -Path $WindowsOptionalFeatureJson | ConvertFrom-Json $WindowsOptionalFeature = $WindowsOptionalFeature | Where-Object {$_.State -eq 2} foreach ($Item in $WindowsOptionalFeature) {Write-Host "$($Item.FeatureName)"} } #=================================================================================================== Write-Verbose '19.1.1 Windows Optional Features (EnablePending)' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Windows Optional Features (EnablePending)" -ForegroundColor Green $WindowsOptionalFeatureJson = Join-Path $($Media.FullName) (Join-Path "info" (Join-Path "json" "Get-WindowsOptionalFeature.json")) if (Test-Path $WindowsOptionalFeatureJson) { $WindowsOptionalFeature = Get-Content -Raw -Path $WindowsOptionalFeatureJson | ConvertFrom-Json $WindowsOptionalFeature = $WindowsOptionalFeature | Where-Object {$_.State -eq 3} foreach ($Item in $WindowsOptionalFeature) {Write-Host "$($Item.FeatureName)"} } #=================================================================================================== Write-Verbose '19.1.1 Windows Optional Features (Disabled)' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Windows Optional Features (Disabled)" -ForegroundColor Green $WindowsOptionalFeatureJson = Join-Path $($Media.FullName) (Join-Path "info" (Join-Path "json" "Get-WindowsOptionalFeature.json")) if (Test-Path $WindowsOptionalFeatureJson) { $WindowsOptionalFeature = Get-Content -Raw -Path $WindowsOptionalFeatureJson | ConvertFrom-Json $WindowsOptionalFeature = $WindowsOptionalFeature | Where-Object {$_.State -eq 0} foreach ($Item in $WindowsOptionalFeature) {Write-Host "$($Item.FeatureName)"} } #=================================================================================================== Write-Verbose '19.1.1 Windows Optional Features (Disabled with Payload Removed)' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Windows Optional Features (Disabled with Payload Removed)" -ForegroundColor Green $WindowsOptionalFeatureJson = Join-Path $($Media.FullName) (Join-Path "info" (Join-Path "json" "Get-WindowsOptionalFeature.json")) if (Test-Path $WindowsOptionalFeatureJson) { $WindowsOptionalFeature = Get-Content -Raw -Path $WindowsOptionalFeatureJson | ConvertFrom-Json $WindowsOptionalFeature = $WindowsOptionalFeature | Where-Object {$_.State -eq 6} foreach ($Item in $WindowsOptionalFeature) {Write-Host "$($Item.FeatureName)"} } } #=================================================================================================== Write-Verbose '19.1.1 Windows Update Packages' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Windows Update Packages" -ForegroundColor Green $GetWindowsPackageJson = Join-Path $($Media.FullName) (Join-Path "info" (Join-Path "json" "Get-WindowsPackage.json")) if (Test-Path $GetWindowsPackageJson) { $GetWindowsPackage = Get-Content -Raw -Path $GetWindowsPackageJson | ConvertFrom-Json $GetWindowsPackage = $GetWindowsPackage | Where-Object {$_.PackageName -like "*Package_for*"} foreach ($Item in $GetWindowsPackage) {Write-Host "$($Item.PackageName)"} } #=================================================================================================== Write-Verbose '19.1.1 Windows Image Information' #=================================================================================================== Write-Host '========================================================================================' -ForegroundColor DarkGray Write-Host "Windows Image Information" -ForegroundColor Green $GetWindowsImageJson = Join-Path $($Media.FullName) (Join-Path "info" (Join-Path "json" "Get-WindowsImage.json")) if (Test-Path $GetWindowsPackageJson) { $GetWindowsImage = Get-Content -Raw -Path $GetWindowsImageJson | ConvertFrom-Json if ($GetWindowsImage.Architecture -eq '0') {$GetWindowsImage.Architecture = 'x86'} if ($GetWindowsImage.Architecture -eq '6') {$GetWindowsImage.Architecture = 'ia64'} if ($GetWindowsImage.Architecture -eq '9') {$GetWindowsImage.Architecture = 'x64'} if ($GetWindowsImage.Architecture -eq '12') {$GetWindowsImage.Architecture = 'x64 ARM'} $GetWindowsImage | Format-List } } } } END { #Write-Host '========================================================================================' -ForegroundColor DarkGray #Write-Host "$($MyInvocation.MyCommand.Name) END" -ForegroundColor Green } } |