-
Posts
82 -
Joined
-
Last visited
-
Days Won
2
Everything posted by syparon
-
List Collection Variables - Powershell
syparon replied to syparon's topic in Configuration Manager 2012
Thanks Kevlar01 I just succeed at the same time you posted Param( [string]$Collection ) #/ Session Creation /*--------------------------------------------------------------------------------------------- Try { $MySession = New-PSSession $ServerHostName } Catch{ Write-Host "Error: $($_.Exception.Message)" } #/----------------------------------------------------------------------------------------------------------------- #/----------------------------------------------------------------------------------------------------------------- #/----------------------------------------------------------------------------------------------------------------- Invoke-Command -session $MySession -ArgumentList $Collection -script { param ($Collection) #/ Import Module + Change Drive /*--------------------------------------------------------------------------------- Import-Module "Path TO Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1" $SCCMDrv = Get-PSDrive -PSProvider CMSite cd "$($SCCMDrv):" #/----------------------------------------------------------------------------------------------------------------- $CollectionInfos = Get-WmiObject -Namespace "Root\SMS\Site_$SiteCode" -Class SMS_Collection -Filter "Name='$Collection'" | Select CollectionID $CollectionID = $CollectionInfos.CollectionID $MyCollection = Get-WmiObject -Namespace Root\SMS\Site_$SiteCode -Class SMS_CollectionSettings -Filter "CollectionID = '$CollectionID'" $MyCollection.Get() foreach($Value in $MyCollection.CollectionVariables) { $Value # OR $Value.Name } Exit } You can call your script by using the following command : Powershell -ExecutionPolicy Unrestricted -File ListDeviceCollectionVariables.ps1 -Collection "My Collection Name" -
Hello gents, I noticed that during an OS deployment once the configuration manager is installed, we can see that the machine is present in SCCM but there is no activity status and so on ... Is there a way to send or update DDR during the task sequence ?
-
Hello gents, I would like to know how delete collection variable for a specific collection filetered by name
-
Hello I would like to know how to list collection variables with powershell
-
Hello, I have a question i am trying to install applications with an OSD task sequence. I defined a base variable called SOFT, and in a device collection I create some variables SOFT1, SOFT2,... followed by the name of some applications. How can I retreive these variable from the device collection to my task sequence
-
How to add a PC to an AD group in OSD Task Sequence
syparon replied to Daneo's topic in Configuration Manager 2012
Hey, I do not know how to display AD Security groups but I knw hot set the membership during the task sequence. You just have to create a SCCM Package which contain a powershell script : function FindGn { param([string]$GroupName) $Root = [ADSI]'' $Query = new-object System.DirectoryServices.DirectorySearcher($Root) $Query.filter = "CN=$GroupName" $Group = $Query.findall() return $Group[0].path } foreach ($Group in $Args) { $SysInfo = New-Object -ComObject "ADSystemInfo" $HostN = $SysInfo.GetType().InvokeMember("ComputerName", "GetProperty", $Null, $SysInfo, $Null) $GroupN = FindGN $Group $GroupN = [ADSI]$GroupN $GroupN.Add("LDAP://$HostN") } If the script is called SetMembership The command line Task in you TS must be : Powershell -ExecutionPolicy Bypass -File SetMembership.ps1 "Group 1" " Group 2 " "..." (http://hpics.li/1be2458) I hope it could help you Bye -
Refresh Device collection Membership
syparon replied to syparon's topic in Configuration Manager 2012
ok Thanks, I have tried to output the result in a file but it seems that it is not possible. Is there another way to capture log about my script or redirect the output in a file because I want to know the result of my script -
Hi all, My goal is to Install applications with Dynamic Varibales which are set in a Device Collection. I created a query to link my device collection with an AD Security group (<-- It works) So during the task sequence I put the Computer as member of a security group (<-- It works) After this I execute a script which make a forest discovery and an update membership for the device Collection (Script is below) Param( [string[]]$Collections ) #/ Session Creation /*--------------------------------------------------------------------------------------------- Try { $MySession = New-PSSession [serverHostName] } Catch{ Write-Host "Error: $($_.Exception.Message)" } #/----------------------------------------------------------------------------------------------------------------- Invoke-Command -session $MySession -ArgumentList $Collections -script { param ($Collections) $Collections = $Collections.Split(',') #/ Import Module + Change Drive /*--------------------------------------------------------------------------------- Import-Module "E:\Services\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1" $SCCMDrv = Get-PSDrive -PSProvider CMSite cd "$($SCCMDrv):" #/----------------------------------------------------------------------------------------------------------------- ###################################################################################### ################################ Forest Discovery #################################### ###################################################################################### Invoke-CMForestDiscovery -SiteCode "[siteCode]" ## ###################################################################################### #/---------------------------------------------------------------------------------------------------------------/# ###################################################################################### ################### Update Membership - Software Baseline ######################## ###################################################################################### $SiteCode = "[siteCode]" $SiteServer = "[serverHostName]" foreach ($Value in $Collections) { echo $Values Try{ $CollectionQuery = Get-WmiObject -Namespace "Root\SMS\Site_$SiteCode" -Class SMS_Collection ` -ComputerName $SiteServer -ErrorAction STOP -Filter "Name='$Value'" $CollectionQuery.RequestRefresh() } Catch{ Write-Host "Error: $($_.Exception.Message)" } } ## ###################################################################################### EXIT } Start-Sleep -s 30 (The task picture is joined to this topic) When I execute the script on a machine it works well and when I execute it through a task sequence I can see in SMSTS log that the task is successfull (Successfully completed the action (Refresh membership) with the exit code 0) But it does not update the membership at all ! Is it because of the configuration manager client ? or something else maybe ? I hope I was clear Thanks in advance