Reputation: 40534
For example, I am looking for a command like this which will update only packages that start with the name PackagePrefix
:
Update-Package "PackagePrefix.*"
I tried the script provided in the comments section of this blog, but it is throwing the following error:
Get-Package | Where Id -like "Contoso.*" | Sort-Object -Property Id -Unique | foreach { Update-Package $_.Id }
Where-Object : Cannot bind parameter 'FilterScript'. Cannot convert the "Id" value of type "System.String" to type "System.Management.Automation.ScriptBlock". At line:1 char:20 + Get-Package | Where <<<< Id -like "Contoso.*" | Sort-Object -Property Id -Unique | foreach { Update-Package $_.Id } + CategoryInfo : InvalidArgument: (:) [Where-Object], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.WhereObjectCommand
Upvotes: 2
Views: 590
Reputation: 40534
After fiddling around a little bit, I figured that I am using a very old version of Powershell (v2.0) and based on the documentation the following script works now. I replaced Where
with Where-Object
:
Get-Package | Where-Object {$_.Id -like "Contoso.*"} | Sort-Object -Property Id -Unique | foreach { Update-Package $_.Id }
Upvotes: 1