Reputation: 5941
This code runs perfectly fine locally:
$objAutoUpdate = New-Object -ComObject "Microsoft.Update.AutoUpdate"
$objautoupdate.settings
This however does NOT return anything:
Invoke-Command -ComputerName qaildc01 -ScriptBlock {
$objAutoUpdate = New-Object -ComObject "Microsoft.Update.AutoUpdate"
$objautoupdate.settings
}
Actually even when using Enter-Pssession running the above object command does not return anything.
Upvotes: 1
Views: 282
Reputation: 13
You are not getting a result for a reason, but you're not getting that reason returned back to you.
Lets debug it :)
So, first.. try to create the object on the remote machine and get all the properties of the object back
Invoke-Command -ComputerName MACHINENAME-HERE -ScriptBlock {
$PSAUObject = (New-Object -ComObject "Microsoft.Update.AutoUpdate")
$PSAUObject | Select *
}
you should get something like that:
Settings :
ServiceEnabled :
Results : System.__ComObject
PSComputerName : MACHINENAME
RunspaceId : 3a951a05-9856-4ad2-8978-1b5827c42e32
now, you will probably get in return all the available properties of the object, Settings seems to be empty but you will be able to access the Results property try the following:
Invoke-Command -ComputerName MACHINENAME-HERE -ScriptBlock {
$PSAUObject = (New-Object -ComObject "Microsoft.Update.AutoUpdate")
$PSAUObject | Select -ExpandProperty "Results"
$PSAUObject | Select -ExpandProperty "Settings"
}
While trying to retrieve the Settings property, i received an exception, probably due to UAC
Exception getting "Settings": "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
+ CategoryInfo : InvalidResult: (System.__ComObject:PSObject) [Select-Object], GetValueInvocationException
+ FullyQualifiedErrorId : PropertyEvaluationExpand,Microsoft.PowerShell.Commands.SelectObjectCommand
Good luck :)
Upvotes: 1