param( [Parameter(Mandatory = $true)] [string]$Path ) $ErrorActionPreference = 'Stop' $item = Get-Item -LiteralPath $Path if (-not $item.PSIsContainer -and $item.Extension -ieq '.exe') { [pscustomobject]@{ productVersion = [string]$item.VersionInfo.ProductVersion fileVersion = [string]$item.VersionInfo.FileVersion productName = [string]$item.VersionInfo.ProductName fileDescription = [string]$item.VersionInfo.FileDescription } | ConvertTo-Json -Compress exit 0 } throw "Not an executable file: $Path"