Jump to content


  • 0
Jepeto 46

Script direct membership based on status filter rule (10800)

Question

Hi all

 

I have a unique situation, here is what i would like to do, unfortunatley not too skilled with PS.

Every time a message ID 10800 is generated

(10800 Informational Advanced Client The SMS Advanced client was installed. The current version is %1.)

i would like to check for the left 3 characters of the computer and based on that add it to a specific collection. the collection is a direct membership with OSDAllowed = False, so no one can deploy to that system by mistake.

Any help on how to do this greatly appreciated.

Update:

I actually had to use 10804, which is when the client is assigned. I am sure there is a way for a nicer and cleaner code :-(

<>

 

<#
Add every new XP client computer to the relevant Site-NoOSD collection based on its name
and filter rule, Genrating message ID 10800, and than 10804, site assigned.
#>
# Import the SCCM server moudle when testing outside SCCM Server
#import-module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1'
Set-Location HQ1:
# SCCM Server
# $CMServerName = "HQCM01"
# Get the new device name from the Filter message
$DeviceName = $args[0]
# Collections to use
$HQCollectionName = "HQ NO OSD"
$NYCollectionName = "NY NO OSD"
$LACollectionName = "LA NO OSD"
# Get the left three characters of the computer name
$a= hostname
$a=$a.Substring(0,3)
# Add to the NoOSD site-Collection
If ($a -eq "HQ-") {Add-CMDeviceCollectionDirectMembershipRule -CollectionName "$HQCollectionName" -ResourceID $(get-cmdevice -name "$DeviceName").ResourceID}
elseif ($a -eq "LA-") {Add-CMDeviceCollectionDirectMembershipRule -CollectionName "$LACollectionName" -ResourceID $(get-cmdevice -name "$DeviceName").ResourceID}
elseif ($a -eq "NY-"){Add-CMDeviceCollectionDirectMembershipRule -CollectionName "$NYCollectionName" -ResourceID $(get-cmdevice -name "$DeviceName").ResourceID}
else {write-host "Not a known site client"}

<>

In the filter, script.ps1 %msgsys

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.