Skip to main content

SCCM Server Groups


What Are Server Groups?

Within SCCM Assets and Compliance you can create a collection containing Server Client membership. Once the 'Server Group' feature is enabled the properties of the collection will contain an additional option to declare that all members of the collection are part of a server group.  This means SCCM knows that the servers within this collection must be treated with specific logic and settings.

In the example below the collection contains three nodes of a cluster and only one node may be Software Updated at a time.

























Once policy is received for the Software Update Group deployment an election is held in which one of the nodes will engage a lock state forcing the other nodes to wait until it has been released.

The UpdatesDeployment.log details the 'Lock State'. Once the node has taken the lock (Lock State: 1) the server will then run the 'Node Drain Script' and continue if the script has an exit code of 0 zero or if the script times out (600 seconds default).

After the main deployment is complete the 'Node resume script' is run and the lock state is returned to 2.

'Node Drain Script' [Untested in Production]
<#
Script Disclaimer: The sample scripts provided here are not supported under any Microsoft standard support program or service. All scripts are provided AS IS without warranty of any kind.
Server Group - Drain Stop Script
Collects current operation status of all nodes in Cluster - i.e. Paused, Running
Checks if Localhost is Paused -- $LocalNodeStatus=$True
Checks if additional nodes in cluster are paused $AdditionalNodeStatus=$True
If $LocalNodeStatus=$False and $AdditionalNodeStatus=False Drain Stop the local node
Checks that the local node is in Paused State
Check that all the VM have evacuated the node
If the $LocalNodeStatus=$False or $LocalVMNodeStatus=$False implying the drain stop has not been successful report failure
Issue exit code 1 and revert the node to Running
Author:
Twitter @Syswow64blog
Web: systemcenterblog.co.uk
#>
#//Initialize
$LocalNodeIsPaused = $False
$LocalVMNodeStatus = $False
$OtherNodesOffline = @()
$LocalNode = $env:computername
#//Setting the log location
$env:LogPath = "$env:ProgramData\SystemCenterBlog\Logs"
#// Checking the log path
if((Test-Path $env:logpath) -eq $False)
{
New-Item -path $env:LogPath -type directory
}
#Starting the log file
Start-Transcript -path "$env:LogPath\PatchDrain.log" -append
#// SMTP Config
$mail = 'mail.SystemCenterBlog.co.uk'
$smtp = New-Object Net.Mail.SmtpClient($mail)
$from = 'SCCMReports@SystemCenterBlog.co.uk'
$to = 'Jonathan.Proctor@SystemCenterBlog.co.uk'
$sub = "Patch Start Script on [$LocalNode] $Node"
#// Functions
Function SendMail($subject,$message,[switch] $fail = $False) {
Write-Output "$subject`: $message"
$smtp.Send($from,$to,$subject,$message)
if ($Fail) {Throw $message}
}
Function Check-VMNodeStatus{
Param($NodeName)
Process
{
$count = 0
Do
{
write-host "$NodeName Checking Node has evacuated all running VM's.............. $(get-date)"
start-sleep 5
[void](Suspend-ClusterNode -drain -wait) # Graceful VM migration
#[void](Suspend-ClusterNode -drain -forcedrain -wait) # Forceful VM migration
$count += 1
}
Until (((get-VM).count -eq 0) -or ($count -eq 3))
if ($count -eq 3){return $False}
else {return $True}
}
}
Function Pause-LocalNode{
Param($NodeName)
Process
{
$count = 0
Write-host "$NodeName Drain node ...................... $(get-date)"
Suspend-ClusterNode -drain -wait
#Check that local node has been Paused
Do
{
write-host "$NodeName Checking Node is in a Paused state........................ $(get-date)"
start-sleep 2
$count += 1
#$PausedClusterNodes = Get-WmiObject -Class "MSCluster_Node" -Namespace "root\MSCluster" | Where-Object {$_.state -eq 2}
}
Until ((Get-WmiObject -Class "MSCluster_Node" -Namespace "root\MSCluster" | Where-Object {$_.state -eq 2}).name -eq $NodeName -or $count -eq 60)
if ($count -eq 20)
{
write-host "$NodeName did not enter a Paused state ........................................... $(get-date)"
return $False
}
else
{
write-host "$NodeName is in a Paused state ........................................... $(get-date)"
return $True
}
}
}
Function Write-Output{
Param($Node,$OperationStatus,$NodePaused,$VMStatus)
Process
{
write-host "$Node has Operation Status $OperationStatus ...... $(get-date)"
write-host "$Node $ LocalNodeStatus = $NodePaused .......... $(get-date)"
write-host "$Node $ LocalVMNodeStatus = $VMStatus ............ $(get-date)"
}
}
#Get Cluster Node Status
$ClusterNodes = Get-WmiObject -Class "MSCluster_Node" -Namespace "root\MSCluster"
foreach ($CNode in $ClusterNodes)
{
if($CNode.State -eq 2) # Paused state
{
if ($CNode.name -eq $LocalNode) # check if local node is paused
{
$LocalNodeIsPaused=$True
write-host "Local node in Paused state = $LocalNodeIsPaused -- "$CNode.name" .... $(get-date)"
}
else # another node is paused
{
$OtherNodesOffline += $CNode.name + "," + $CNode.state
write-host "Additional node in Paused State Will not proceed-- "$CNode.name" .... $(get-date)"
}
}
elseif ($CNode.State -eq 1) # Check for Failed state and exit
{
write-host "Node is in failed state = $CNode.name .... $(get-date)"
$OtherNodesOffline += $CNode.name + "," + $CNode.state
}
}
if ($OtherNodesOffline.count -gt 0)
{
if ($LocalNodeIsPaused) # Resume the local node if this is paused also as the SCCM script is going to fail
{
Resume-ClusterNode
}
foreach ($Node in $OtherNodesOffline)
{
$NodeName = $Node.split(",")[0]
$NodeState = $Node.split(",")[1]
write-host ""$NodeName" has Operation Status $NodeState .... $(get-date)"
}
write-host "SCCM Exit code 1................................................$(get-date)"
Return 1
}
else
{
if ($LocalNodeIsPaused -eq $False) # No nodes are paused, pause the local node
{
$LocalNodeIsPaused = Pause-LocalNode -NodeName $LocalNode # try to pause local node
}
if($LocalNodeIsPaused -eq $True) # Only Local Node paused, check VM Count
{
$CheckVMNode = Check-VMNodeStatus -NodeName $LocalNode
Write-Output -Node $LocalNode -OperationStatus 2 -NodePaused $LocalNodeIsPaused -VMStatus $CheckVMNode
if ($CheckVMNode -eq $true) # VM Status is true
{
write-host "SCCM Exit code 0................................................$(get-date)"
Return 0
}
else # VM Status is false
{
write-host "SCCM Exit code 1................................................$(get-date)"
Return 1
}
}
else
{
$NodeStatus = Get-WmiObject -Class "MSCluster_Node" -Namespace "root\MSCluster" | Where-Object {$_.name -like $LocalNode}
$CheckVMNode = Check-VMNodeStatus -NodeName $LocalNode
Write-Output -Node $LocalNode -OperationStatus $NodeStatus.state -NodePaused $LocalNodeIsPaused -VMStatus $CheckVMNode
Write-Host "SCCM Exit code 1................................................$(get-date)"
Return 1
}
}

'Node resume script'
Resume-ClusterNode

Lock States
There are four lock states:

Waiting for Lock: 0
Have Lock: 1
Released Lock: 2
Node Script Failed: 3


The SQL script below will report on all Server Groups with Pre and Post Actions as well as current client Lock states.

/* Script Disclaimer: The sample scripts provided here are not supported under any Microsoft standard support program or service.
All scripts are provided AS IS without warranty of any kind.
*/
Select
c.Name [CollectionName],
LastModificationTime,
UseCluster,
UseClusterPercentage,
PreAction,
PostAction,
ClusterCount,
ClusterPercentage,
ClusterTimeout
From
vSMS_CollectionSettings cs join v_Collection c on cs.CollectionID = c.CollID
Where
UseCluster = 1
Select
c.Name [CollectionName], s.Name0 [SystemName], dm.[State], dm.[TimeStamp]
From DeploymentMutex dm
join v_R_System s ON s.ResourceID = dm.ResourceID
join v_Collection c ON c.CollID = dm.CollectionID
Order By c.Name, dm.[State] Desc
/*
Lock States
There are four lock states:
Waiting for Lock: 0
Have Lock: 1
Released Lock: 2
Node Script Failed: 3
--
*/
gg

Comments

  1. We created the software program with eyesight to provide companies worldwide high-quality internet structures which easily simplify the way they do business
    web design & development company

    ReplyDelete
  2. I would like to thank the developers of this super mobile app consultancies
    services website for this hyperlink and to supply us with the comfortability for incomes after the utilization of it!

    ReplyDelete
  3. If somebody wants expert take on the main topic of blogging next I advise him/her to go to this site, continue the fussy job.
    interactive design firms

    ReplyDelete
  4. If somebody wants expert take on the main topic of blogging next I advise him/her to go to this site, continue the fussy job.
    best logo design company in the world

    ReplyDelete
  5. It’s amazing to visit again n again coming to your blogs the superb effort is here.
    top website designing companies

    ReplyDelete
  6. Our writers provide you with operations assignment help and additional examples of operations management assignments. operations management homework help

    ReplyDelete
  7. Oral surgery is a broad term for any operation performed on your teeth, gums, jaw or surrounding oral and facial structures. Dental Surgery

    ReplyDelete

Post a Comment

Popular posts from this blog

SCCM Unknown computer not able to see Task Sequences after installing Current Branch 1702

Soon after installing SCCM CB 1702 we were unable to see Task Sequences deployed to the unknown collection. This issue was identified as a random system taking the GUID of the 'x64 Unknown Computer (x64 Unknown Computer)' record. As a result it was now a known GUID; as we were only deploying Task Sequences to the Unknown collection none were made available. 'x64 Unknown Computer (x64 Unknown Computer)' record 'x86 Unknown Computer (x86 Unknown Computer)' record To get the GUID of your unknown systems open SQL management studio and run the following command: --Sql Command to list the name and GUID for UnknownSystems record data select ItemKey, Name0,SMS_Unique_Identifier0 from UnknownSystem_DISC Using the returned GUID (SMS_Unique_Identifier0) we can find the hostname that has been assigned the 'x64 Unknown Computer (x64 Unknown Computer)' GUID by running the query below. --x64 Unknown Computers select Name0,SMS_Unique_Identifier0,Decommissioned0 from Sys...

Windows 7 Offline files will not go Online when connected to network

Issue Several laptop users move between networks, domain, home, etc and when they attempt to access DFS shares explorer status is working offline.  The issue only resolves it self after a reboot. Connecting directly to the share works and i am able to ping network resources.  This behavior occurs for VPN users as well. Possible Causes "slow-link mode". In win7 (with default settings) a client will enter slow-link mode if the latency to the server is above 80ms. In slow-link mode all writes are made to the local cache and a background sync only happens every 6 hours.  Depending on your connection the default slow link detection speed is 64,000 bps On client computers running Windows 7 or Windows Server 2008 R2, a shared folder automatically transitions to the slow-link mode if the round-trip latency of the network is greater than 80 milliseconds, or as configured by the "Configure slow-link mode" policy. After transitioning a folder to the slow-link mode, Offline Fil...

Java 7 update 21 (1.7.0_21) Enterprise Repackaged Security Medium Deployment with SCCM

------------------------------------------------------------------------------------------------- Java 7 update 45 Enterprise deployment complete walk through http://www.syswow64.co.uk/2013/10/java-7-update-45-enterprise-deployment.html -------------------------------------------------------------------------------------------------- The issue on many blogs and articles is around creating the 'deployment.config' and 'deployment.properties' files for an enterprise deployment.  In my case i wanted to set the security level to 'Medium', but everytime I open the Java control panel it was set to the default HIGH setting. Solution 1 Create the following directory path 'C:\Windows\sun\java\deployment' 2 Create a file called 'deployment.config' in this directory and open with Notepad. Copy the two line below #################### deployment.system.config = file\:\\C\:\\WINDOWS\\Sun\\Java\\Deployment\\deployment.properties deployment.system...