SCCM Get and Set Assigned Site

Welcome Forums General PowerShell Q&A SCCM Get and Set Assigned Site

This topic contains 1 reply, has 2 voices, and was last updated by

2 years, 3 months ago.

  • Author
  • #55146

    Points: 0
    Rank: Member

    I would like to get the assigned site, set it and get it again to make sure it changed. I got this from the web:

    $([WmiClass]"\\ny7D20360\ROOT\ccm:SMS_Client").GetAssignedSite()| Select sSiteCode 

    errors with get:
    Exception calling "GetAssignedSite" : ""
    At line:1 char:3
    + $([WmiClass]"\\ny7D20360\ROOT\ccm:SMS_Client").GetAssignedSite()| Select sSiteCo ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WMIMethodException
    error with set:
    Cannot find an overload for "SetAssignedSite" and the argument count: "2".
    At line:1 char:3
    + $([WmiClass]"\\ny7D20360\ROOT\ccm:SMS_Client").SetAssignedSite("exe",$null)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
    Can some please help.

  • #55147

    Points: 1,785
    Helping HandTeam Member
    Rank: Community Hero

    So, this is really more an SCCM question, unfortunately, but what it's telling you is that it can't find a version of SetAssignedSite() that accepts the two arguments you provided. I went to, and it seems to want a site code as a string (like "exe" I suppose), but then it wants a long integer as a set of flags. You might try passing a zero instead of $null?

    This is really outside PowerShell per se, and even worse it's an old COM class (the docs are from 2009!). COM doesn't always intro cleanly with .NET and PowerShell, so it may take some fiddling to figure out. It could also be a problem with the version of SCCM you're using – the docs indicate compatibility with 2007, but nothing later.

The topic ‘SCCM Get and Set Assigned Site’ is closed to new replies.