IT 专业人士的资源 > 论坛主页 > The Official Scripting Guys Forum! > Sharing folder via WMI: Win32_Account from remote?
提出问题提出问题
 

建议的答复Sharing folder via WMI: Win32_Account from remote?

  • 2009年7月1日 10:54Jakob Svendsen版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    Hello everyone

    I have been working on some functions for crating share via WMI (Win32_Share), with custom permissions.

    but i have one issue.

    I use the Win32_Account class to find the user/group's SID, it works great when questioning the local machine.
    but when trying to retrieve them frmo a remote machine, it only gives me the local users.

    I think that this is by design?
    but is there any way i can retrieve the SID's from the remote PC via WMI ?
    (in case this PC is on another domain than me, but i have special permissions to connect via WMI).

    You can download my script at
    http://blog.coretech.dk/scripting/powershell-wmi-working-with-shares-part-1-creating-a-share-with-custom-permissions/

    Please provide any feedback if you have it. I want to continue improving the script (this is version 0.0.1)

    thanks! :)
    Best Regards
    Jakob Gottlieb Svendsen

    Trainer/Consultant - Coretech A/S - Blog - MCT - MCTS - VB.NET - C#.NET - Powershell - VBScript

全部回复

  • 2009年7月1日 15:26AbqBill版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     包含代码
    Hi Jakob,

    This works for me:

    gwmi Win32_Account -computer servername
    

    Bill
  • 2009年7月2日 14:21Jakob Svendsen版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    Hello

    Thank you for testing


    Does it show all domain users too on your system?

    I was testing from a vista Pc to another vista.




    Trainer/Consultant - Coretech A/S - Blog - MCT - MCTS - VB.NET - C#.NET - Powershell - VBScript
  • 2009年7月2日 14:47AbqBill版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     包含代码
    Hi Jakob,

    get-wmiobject Win32_Account -computername servername

    only retrieves Win32_Account objects on the named computer. To retrieve domain accounts, you can use

    get-wmiobject Win32_Account -filter "Domain='domainname'"

    HTH,

    Bill
  • 2009年7月3日 8:01Jakob Svendsen版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     包含代码
    Hello agani :)

    thanks for trying to help :) :)

    but i think you may have misunderstood my problem.

    get-wmiobject Win32_Account -computername servername
    Correct, this retrieves accounts from the remote PC, but only the local accounts from that PC.
    If the PC has joined another domain, you cannot get the accounts from that domain.

    get-wmiobject Win32_Account -filter "Domain='domainname'"
    yes its the same as when i use the [WMI] accellerator on the local PC.
    But this only gives the domain accounts for the doman, from which the local PC is joined.
    if a remote PC has joined another domain that the macihne running the script, you cannot retrieve info on those accounts.

    so my problem is (and i gues it cannot be solved) that i cannot get those accounts, from the remote PC.
    Have a nice weekend! :)


    - Jakob
    Trainer/Consultant - Coretech A/S - Blog - MCT - MCTS - VB.NET - C#.NET - Powershell - VBScript
  • 2009年7月3日 16:03AbqBill版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     建议的答复
    Hi Jakob,

    A brief search didn't reveal such such a limitation provided your script provides appropriate credentials to allow it to query accounts on a different domain. In that case, my thought would be to query the accounts on a domain controller rather than a member machine. But I am unable to test here as I only have a single domain.

    Regards,

    Bill