Search the Community
Showing results for tags 'Poweshell'.
-
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