How do you create embedded (temp) WMI objects using PowerShell?
i'm working system center configuration manager (sccm), , i'm trying create maintenance window using powershell , wmi. the sccm sdk shows how via c#, helpful. but 1 of steps create temporary wmi embedded object, never gets instantiated on own. how done in powershell?
i'm familiar creating wmi objects via set-wmiinstance, example follows:
$hashobj = @{ 'name'=$collectionname ; 'ownedbythissite'='true' } $coll = set-wmiinstance -namespace $cmnamespace -class sms_collection -arguments $hashobj
// create collection settings object. var collectionsettingsinstance = connection.createinstance("sms_collectionsettings"); // create embedded object. var svcwindowinstance = connection.createembeddedobjectinstance("sms_servicewindow"); // add embedded object. collectionsettingsinstance.setsingleitem("servicewindows", svcwindowinstance); collectionsettingsinstance.put();
well can (most times) use .net objects in powershell loading namespace in , creating new object of type.
for example
[system.reflection.assembly]::loadwithpartialname("system.windows.forms")
and you'd use new-object make object of type , work other object.
for part pretty easy change c# ps
Windows Server > Windows PowerShell
Comments
Post a Comment