Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Combining scripts or using one to input to the next

I have 2 Powershell scripts and they both work really well – but I now want to combine them and am not sure how to go about it.

The first script is (this provides details of apps installed from the Store):

Get-AppxPackage | Select Name, InstallLocation, PackageFamilyName, Target

The second script is (which provides the application id – which is required to launch the app through code):

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

(Get-AppxPackage -Name "*ADD PACKAGE NAME*" | Get-AppxPackageManifest).package.applications.application.id

If possible – I’d either want the above combined in one script where the application id could be appended to an additional column – or I’d like the first script to feed/input the second script.

>Solution :

# Get packages and select needed properties
$packages = Get-AppxPackage | Select Name, InstallLocation, PackageFamilyName, Target

# add foreach through each package 
foreach ($package in $packages) {
    $appName = $package.Name
    $appId = (Get-AppxPackage -Name $appName | Get-AppxPackageManifest).package.applications.application.id

    # Set the Application ID to the object as a new
    $package | Add-Member -MemberType NoteProperty -Name "ApplicationId" -Value $appId
}

# Output (combined result)
$packages
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading