Using the SCClient Powershell module, I'm trying to install an individual update from a list of updates in the Software Center.
I can create a variable like this:
$ids = Get-SCCLientPendingUpdate *server* | select-object updateid
and $ids will output something like:
UpdateID
--------
Site_siteid/SUM_446bbb5d-743f-486c-94dc-61c3dce48e75
Site_siteid/SUM_f444ac52-95a6-4a47-95bb-51c2694120fb
Site_siteid/SUM_426ce60a-8e6e-4c8d-ae46-a1329b0b6b2c
When I try to run the following:
Start-SCClientInstallUpdates *server* -updateid $ids[0]
I get an error stating:
MethodInvocationException: Exception calling "InstallUpdates" with "1" argument(s): "Unable to cast object of type 'System.Management.Automation.PSObject' to type 'System.Array'."
Not sure of a good way to deal with this, I was thinking of assigning each updateID to its own variable as a string, but there is no information that I could find to accomplish this and seems a little clunky anyways. [string]$ids[0] outputs this:
@{UpdateID=Site_siteid/SUM_446bbb5d-743f-486c-94dc-61c3dce48e75}
I'm assuming this is part of the problem, but I can't figure out how to remove the "extra" stuff from it being an array, or how to save the original variable ($ids) differently. I can reference a variable with -updateid $var if the variable is saved like this:
$var = "Site_siteid/SUM_446bbb5d-743f-486c-94dc-61c3dce48e75"
Maybe I'm going about this wrong or missing something simple I'm not sure, but I can't find this error anywhere online and the few things I tried to convert it to a string seems to still reference the thing as an array, so I don't know what I'm missing.
I've tried:
[string]$ids[0] $ids[0].updateid
setting $ids[0] to its own variable (same error as before)
$idarray = $ids | foreach {"$($_.UpdateID)"} and then using $idarray for the -updateid (same error, unable to cast object...to type 'system.array')
enclosing the variable in quotes ( -updateid "$ids[0]" , "$idarray" , etc.)