Grab our RSS feeds Follow us on Twitter Join our Facebook Group Connect with us on LinkedIn
myITforum.com, Powered by You.
you are not logged in

Articles

Newslinks

Links

Downloads

Site Services

Community Forums

Discussion Lists

Article Search

Newsletter

Web Blogs

FAQs

Live Support

myITforum TV

Take a Poll

Monthly Drawing

myITforum Network

User Group Directory

Our Partners

About Us

Register

Login

BRONZE PARTNER:

BRONZE PARTNER:



Industry News:




  Home : Articles : Windows PowerShell print | email | | Forums |   print | email | | Blogs |   print | email | | Wiki |   print | email | | FAQs |   print | email | Article Search  
PowerShell: How do I connect to SMS 2003 and perform Client Actions?


Bookmark and Share

By: Shaun Cassells
Posted On: 6/23/2008

The Microsoft.SMS.Client COM object exposes several client actions.

PS C:\ > $a = New-Object -comObject Microsoft.SMS.Client

Now what do I do with the $a variable? Let’s see what members are exposed from the COM.

PS C:\> New-Object -comObject Microsoft.SMS.Client | get-member

Note: the following results are contained in the SMS 2003 SDK 3.1

  • AutoDiscoverSite
    o Retrieves the site code of the locally available site based on the client's current roaming situation, without assigning the client to the site
  • DiscoverDefaultMP
    o Retrieves the assigned management point for a client, without assigning the client to the management point.
  • EnableAutoAssignment
    o Enables or disables the auto-assignment feature of the client.
  • GetAssignedSite
    o Gets the currently assigned site of the client
  • GetCurrentManagementPoint
    o Gets the management point to which the client is currently assigned.
    o Note: This method is deprecated. Use the ISmsClient2::GetCurrentManagementPointEx Method
  • ReAssignSite
    o Forces the client to rediscover its assigned site and then reassign itself to that site.
  • RemoveAssignedSites
    o Removes all site assignments for the client
  • ResyncPolicy
  • SetAssignedSite
    o Sets the client's assigned site
  • SetCurrentManagementPoint
    o Sets the current management point for the client
  • UseAdminLocator
  • Local administrator privileges are required to call this interface.
    o The IID for ISmsClient is DF56E387-A8BF-409a-8D1C-33CD1908C01A

Cool, show me how to use one.

PS C:\ > $a.AutoDiscoverSite()

Returns the 3 char Site Code

Example: Change a site code, force a policy resynchronization, then set client back to default Site Code.

PS C:\ > $a = New-Object -comObject Microsoft.SMS.Client
1. Check what site is currently assigned
PS C:\ > $a.GetAssignedSite()
2. Change Site Setting to Something else
PS C:\> $a.SetAssignedSite("LAB")
3. Check What site is currently assigned
PS C:\ > $a.GetAssignedSite()
4. Force a policy refresh and send new discovery record
PS C:\> $a.ResyncPolicy()
5. Force the client back to the correct Site Code
PS C:\> $a.ReAssignSite()

Step 2 would fail: if you do not have security rights to perform that action:
Exception calling "SetAssignedSite" with "1" argument(s): "Failed to set the assigned site."At line:1 char:19+ $a.SetAssignedSite( <<<< "LAB")

Step 4 would fail: if you do not have security rights to perform that action:
Exception calling "ResyncPolicy" with "0" argument(s): "Failed to resync policy. One or more settings may be missing from WMI"At line:1 char:16+ $a.ResyncPolicy( <<<< )




  myITforum.com ©2010 | Legal | Privacy