Variable Issue RRS feed

  • Question

  • Sort of new to powershell and having an issue with the below:

    Get-AppxPackage -AllUsers *Microsoft.Bing* | Export-CSV K:\Package.csv
    $Package = Import-Csv "\\ks-appsrv-02\apps$\Package.csv" | Select -ExpandProperty PackageFullName
    Remove-AppxProvisionedPackage -Online -PackageName $Package

    The first line creates a CSV with any Microsoft AppX package in it containing Microsoft.Bing in the name

    The second line gets the full package name (In this case Microsoft.BingWeather_4.31.11905.0_x64__8wekyb3d8bbwe) and assigns it against the variable $Package

    Now the 3rd line should remove the package but I am getting:

    Remove-AppxProvisionedPackage : The system cannot find the file specified.
    At line:1 char:103
    + ... FullName} | Remove-AppxProvisionedPackage -Online -PackageName $Packa ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Remove-AppxProvisionedPackage], COMException
        + FullyQualifiedErrorId : Microsoft.Dism.Commands.RemoveAppxProvisionedPackageCommand

    If I just ran it as Remove-AppxProvisionedPackage -Online -PackageName Microsoft.BingWeather_4.31.11905.0_x64__8wekyb3d8bbwe it would work so I'm not sure what I'm doing wrong here.

    All help is greatly appreciated.

    Wednesday, August 21, 2019 2:26 PM


  • The Remove-AppxProvisionedPackage expects a string, not an array.

    Put the Remove-AppxProvisionedPackage inside a ForEach and remove the individual packages one at a time.

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Wednesday, August 21, 2019 2:54 PM