![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | How to initialize an instance of a WMI System.Management.ManagementClass class Just figured this out and thought it was worth sharing. Should you need to access methods that only exist in the WMI classes themselves and not the instaces (such as the 'Create' method on the Win32_Share class) you can create the object with similar code: $Win32Share = New-Object System.Management.ManagementClass("Win32_Share") Lots more information an additional ways in instantiate System.Management.ManagementClass at http://msdn2.microsoft.com/en-us/library/xywtet7d.aspx I used this info to create shares remotely (was recovering a data volume on a remote server) with: #Create Network Shares using WMI param ($Path = $(throw "Missing $Path parameter"), $Name = $(throw "Missing $Name patameter"), $Type = 0, $MaximumAllowed = $null, $Description = "", $computer = ".") $Win32Share = New-Object System.Management.ManagementClass("Win32_Share") $Win32Share.Create($Path,$Name,$Type,$MaximumAllowed,$Description) Hope that can be of use to someone ![]() |
| | #2 (permalink) |
| Guest | RE: How to initialize an instance of a WMI System.Management.Managemen you can also you the typeexelerator as a shorcut for this : $win32share = [wmiclass]'win32_share' enjoy, Greetings /\/\o\/\/ http://thePowerShellGuy.com "Clint Bergman" wrote: > Just figured this out and thought it was worth sharing. Should you need to access methods that only exist in the WMI classes themselves and not the instaces (such as the 'Create' method on the Win32_Share class) you can create the object with similar code: > > $Win32Share = New-Object System.Management.ManagementClass("Win32_Share") > > Lots more information an additional ways in instantiate System.Management.ManagementClass at http://msdn2.microsoft.com/en-us/library/xywtet7d.aspx > > I used this info to create shares remotely (was recovering a data volume on a remote server) with: > > #Create Network Shares using WMI > param ($Path = $(throw "Missing $Path parameter"), > $Name = $(throw "Missing $Name patameter"), > $Type = 0, > $MaximumAllowed = $null, > $Description = "", > $computer = ".") > > $Win32Share = New-Object System.Management.ManagementClass("Win32_Share") > $Win32Share.Create($Path,$Name,$Type,$MaximumAllowed,$Description) > > Hope that can be of use to someone ![]() |
| | #3 (permalink) |
| Guest | Re: How to initialize an instance of a WMI System.Management.Managemen Thanks MoW! I'm always trying to do stuff the hard way... ![]() I found a list of Type Shortcuts at http://blogs.msdn.com/powershell/arc...12/663540.aspx but is there a way to query PowerShell to find out what accelerators are available? ~Clint "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message news:447D7366-81A7-44FB-A416-6006DB66DF00@microsoft.com... > you can also you the typeexelerator as a shorcut for this : > > $win32share = [wmiclass]'win32_share' > > enjoy, > > Greetings /\/\o\/\/ > http://thePowerShellGuy.com > > "Clint Bergman" wrote: > >> Just figured this out and thought it was worth sharing. Should you need to access methods that only exist in the WMI >> classes themselves and not the instaces (such as the 'Create' method on the Win32_Share class) you can create the >> object with similar code: >> >> $Win32Share = New-Object System.Management.ManagementClass("Win32_Share") >> >> Lots more information an additional ways in instantiate System.Management.ManagementClass at >> http://msdn2.microsoft.com/en-us/library/xywtet7d.aspx >> >> I used this info to create shares remotely (was recovering a data volume on a remote server) with: >> >> #Create Network Shares using WMI >> param ($Path = $(throw "Missing $Path parameter"), >> $Name = $(throw "Missing $Name patameter"), >> $Type = 0, >> $MaximumAllowed = $null, >> $Description = "", >> $computer = ".") >> >> $Win32Share = New-Object System.Management.ManagementClass("Win32_Share") >> $Win32Share.Create($Path,$Name,$Type,$MaximumAllowed,$Description) >> >> Hope that can be of use to someone ![]() |
| | #4 (permalink) |
| Guest | Re: How to initialize an instance of a WMI System.Management.Managemen Good question, I think there is no way to list the type accelerators from PowerShell all the types in the system namespace are available as shortcuts (you can leave out system.) but the accelerators for example those for ADSI and WMI are not listable I think As I think this functionality should be there, if I'm right on this file a feature request on connect and you will get my vote ![]() Greetings /\/\o\/\/ "Clint Bergman" <clint@psd267.wednet.edu> wrote in message news:ub1cpktyHHA.464@TK2MSFTNGP02.phx.gbl... > Thanks MoW! I'm always trying to do stuff the hard way... ![]() > > I found a list of Type Shortcuts at > http://blogs.msdn.com/powershell/arc...12/663540.aspx but is > there a way to query PowerShell to find out what accelerators are > available? > ~Clint > > "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message > news:447D7366-81A7-44FB-A416-6006DB66DF00@microsoft.com... >> you can also you the typeexelerator as a shorcut for this : >> >> $win32share = [wmiclass]'win32_share' >> >> enjoy, >> >> Greetings /\/\o\/\/ >> http://thePowerShellGuy.com >> >> "Clint Bergman" wrote: >> >>> Just figured this out and thought it was worth sharing. Should you need >>> to access methods that only exist in the WMI classes themselves and not >>> the instaces (such as the 'Create' method on the Win32_Share class) you >>> can create the object with similar code: >>> >>> $Win32Share = New-Object >>> System.Management.ManagementClass("Win32_Share") >>> >>> Lots more information an additional ways in instantiate >>> System.Management.ManagementClass at >>> http://msdn2.microsoft.com/en-us/library/xywtet7d.aspx >>> >>> I used this info to create shares remotely (was recovering a data volume >>> on a remote server) with: >>> >>> #Create Network Shares using WMI >>> param ($Path = $(throw "Missing $Path parameter"), >>> $Name = $(throw "Missing $Name patameter"), >>> $Type = 0, >>> $MaximumAllowed = $null, >>> $Description = "", >>> $computer = ".") >>> >>> $Win32Share = New-Object >>> System.Management.ManagementClass("Win32_Share") >>> $Win32Share.Create($Path,$Name,$Type,$MaximumAllowed,$Description) >>> >>> Hope that can be of use to someone ![]() > > |
| | #5 (permalink) |
| Guest | Re: How to initialize an instance of a WMI System.Management.Managemen Suggestion filed on Connect: "List Type accelerators available in PowerShell", thanks for the suggestion on this I often forget that connect is there. On a bit of a side note, how is a guy supposed to figure out the syntax to connect to a remote [wmiclass]? I finally nailed it with trial and error, [wmiclass]\\server\namespace:class, am I just supposed to know the syntax? I couldn't find anything real helpful on msdn, and knowing how to find the answer is usually my goal. Any tips on how to find info like that? Thanks for all your help! -- (^_^)v ~Clint My (very) humble blogger beginnings: http://outputredirection.blogspot.com "/\/\o\/\/ [MVP]" <mow001@hotmail.NoSpam> wrote in message news:%23AuPw1uyHHA.5376@TK2MSFTNGP03.phx.gbl... > Good question, > > I think there is no way to list the type accelerators from PowerShell > all the types in the system namespace are available as shortcuts (you can leave out system.) > but the accelerators for example those for ADSI and WMI are not listable I think > > As I think this functionality should be there, if I'm right on this file a feature request on connect and you will get > my vote ![]() > > Greetings /\/\o\/\/ > > "Clint Bergman" <clint@psd267.wednet.edu> wrote in message news:ub1cpktyHHA.464@TK2MSFTNGP02.phx.gbl... >> Thanks MoW! I'm always trying to do stuff the hard way... ![]() >> >> I found a list of Type Shortcuts at http://blogs.msdn.com/powershell/arc...12/663540.aspx but is there a >> way to query PowerShell to find out what accelerators are available? >> ~Clint >> >> "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message >> news:447D7366-81A7-44FB-A416-6006DB66DF00@microsoft.com... >>> you can also you the typeexelerator as a shorcut for this : >>> >>> $win32share = [wmiclass]'win32_share' >>> >>> enjoy, >>> >>> Greetings /\/\o\/\/ >>> http://thePowerShellGuy.com >>> >>> "Clint Bergman" wrote: >>> >>>> Just figured this out and thought it was worth sharing. Should you need to access methods that only exist in the >>>> WMI classes themselves and not the instaces (such as the 'Create' method on the Win32_Share class) you can create >>>> the object with similar code: >>>> >>>> $Win32Share = New-Object System.Management.ManagementClass("Win32_Share") >>>> >>>> Lots more information an additional ways in instantiate System.Management.ManagementClass at >>>> http://msdn2.microsoft.com/en-us/library/xywtet7d.aspx >>>> >>>> I used this info to create shares remotely (was recovering a data volume on a remote server) with: >>>> >>>> #Create Network Shares using WMI >>>> param ($Path = $(throw "Missing $Path parameter"), >>>> $Name = $(throw "Missing $Name patameter"), >>>> $Type = 0, >>>> $MaximumAllowed = $null, >>>> $Description = "", >>>> $computer = ".") >>>> >>>> $Win32Share = New-Object System.Management.ManagementClass("Win32_Share") >>>> $Win32Share.Create($Path,$Name,$Type,$MaximumAllowed,$Description) >>>> >>>> Hope that can be of use to someone ![]() >> >> > |
| | #6 (permalink) |
| Guest | Re: How to initialize an instance of a WMI System.Management.Managemen On Jul 20, 1:24 pm, "Clint Bergman" <cl...@psd267.wednet.edu> wrote: > On a bit of a side note, how is a guy supposed to figure out the syntax to connect to a remote [wmiclass]? I finally > nailed it with trial and error, [wmiclass]\\server\namespace:class, am I just supposed to know the syntax? I couldn't > find anything real helpful on msdn, and knowing how to find the answer is usually my goal. Any tips on how to find info > like that? bump... I'd like to know in particular how you supply credentials to such a construct as [wmiclass]\\server\namespace:class. $a = get-wmiobject win32_share -comp server -cred $(get-credential) $b = [wmiclass]'\\server\root\cimv2:win32_share' $b is going to fail if I can't supply credentials obviously. Has anyone come across documentation for this? I'm sure it's buried on MSDN somewhere. ![]() |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Computer management & System | Cojo | Vista mail | 0 | 06-20-2008 10:28 PM |
| Windows Easy Transfer - Failed to initialize the logging system | Rafal | Vista General | 2 | 06-06-2008 09:36 AM |
| Using New-Object With ManagementClass | urkec | PowerShell | 4 | 03-06-2008 12:31 PM |
| Initialize Junk Mail Filtering and MSOE.DLL could not initialize | RainbowKid | Vista mail | 13 | 03-04-2008 11:36 PM |
| Issues with System drive in Disk Management on a Dual Boot system | =?Utf-8?B?dGhpbHRvbg==?= | Vista General | 4 | 07-09-2006 06:26 PM |