共用方式為


Configuration Manager Updates and Servicing PowerShell automation coming to 1705 TP

By popular demand, we have added several new cmdlets in the 1705 TP for automating updates and servicing in Configuration Manager. Moving forward this should greatly simplify automated lab deployments and update scenarios.

These cmdlets allow you to do all of the same functionality that you can do in the UI: get updates, download updates, perform a prerequisite check, install updates, and monitor updates installation.

In this post, I will walk through a few scenarios and how you can now automate them in PowerShell.

New cmdlets for updates and servicing automation

The following new cmdlets have been created to automate updates and servicing scenarios:

  • Enable-CMSiteFeature – Used to enable a pre-release feature. Note that this is a one-way operation so there’s no corresponding Disable-CMSiteFeature cmdlet.
  • Get-CMSiteFeature – Gets the available features for the site.
  • Get-CMSiteUpdate – Gets the available updates for the site.
  • Get-CMSiteUpdateHistory – Gets the update history. This is only for informational purposes.
  • Get-CMSiteUpdateInstallStatus – Gets the install status for a particular update. This can be used for monitoring.
  • Install-CMSiteUpdate – Installs an update and allows for optionally skipping prerequisite checking and specifying a pre-release collection.
  • Invoke-CMSitePromotePreproductionClient – Promotes a pre-production client.
  • Invoke-CMSiteUpdateCheck – Checks with Microsoft for any updates to Configuration Manager.
  • Invoke-CMSiteUpdateDownload – Downloads an available update.
  • Invoke-CMSiteUpdatePrerequisiteCheck – Performs a prerequisite check for an update.

In addition to these new cmdlets, Set-CMHierarchySetting has been updated to allow for enabling pre-release features with the –EnablePrereleaseFeature parameter. Note that this is a one-way operation and once you enable pre-release features you cannot disable them.

We hope you find these new cmdlets useful for automating updates and servicing scenarios. Please report any bugs or issues you find with these new cmdlets on UserVoice or Connect.

Examples

Download an update and monitor its status

 
# Get the update object for the 1704 TP and invoke a download
$update = Get-CMSiteUpdate -Name "Configuration Manager Technical Preview 1704" -Fast
$update | Invoke-CMSiteUpdateDownload

# Now monitor the download status

while($true) {
    cls
   $update | Get-CMSiteUpdateInstallStatus  -Step Download | select orderid, progress, description | ft
    sleep 5
}

This will produce an output like this:

 
orderid progress description                                                                                                                                 
------- -------- -----------                                                                                                                                 
      0      100 Processing update package. Check dmpdownloader.log for details.                                                                             
      1        0 If your service connection point is online, the update package cab is downloaded. If your service connection point is offline, this step ...
      2        0 Extracting update package payload. Check dmpdownloader.log for details.                                                                     
      3        0 If redistributable files are required and not included with the update, they are downloaded.  If files do not need to be downloaded, this...
      4        0 The update package has been reported as downloaded. Check dmpdownloader.log and hman.log for details. 

Perform a prerequisite check and monitor its status

 
$update = Get-CMSiteUpdate -Name "Configuration Manager Technical Preview 1704" -Fast
$update | Invoke-CMSiteUpdatePrerequisiteCheck

while($true) {
    cls
    $update | Get-CMSiteUpdateInstallStatus -Step Prerequisite | select orderid, progress, description | ft
    sleep 5
}

This will produce an output like this:

 
orderid progress description                                                                                                                                 
------- -------- -----------                                                                                                                                 
      0      100 Verifies that the logged on user account has administrative rights on the site system computer.                                             
      0      100 Starting with version 1706, Upgrade Assessment Toolkit is no longer supported. https://go.microsoft.com/fwlink/?linkid=841654               
      1      100 Verifies that the user running Setup has local administrator rights on the central administration site server.                              
      2      100 Checks if the user account running Setup has sysadmin rights on the SQL Server for the CAS.                                                 
      3      100 Check Server Service (LanmanServer) is running.                                                                                             
      4      100 Verifies that the computer specified for installation is a member of a Windows domain.                                                      
      5      100 Verify that the Active Directory domain functional level is Windows Server 2003 or later.                                                   
      6      100 Checks that the site server computer has sufficient available disk space to install the site server.                                        
      7      100 Checks if a system restart is pending.                                                                                                      
      8      100 Checking unsupported Read-Only Domain Controller on site server.                                                                            
      9      100 Checking Site Server FQDN Length.                                                                                                           
     10      100 Verifies that the Microsoft Core XML Services (MSXML) version 6.0 or later libraries are installed.                                         
     11      100 Determines if the Windows Server 2003-based schannel hotfix is installed on the site server.                                                
     12      100 Verifies that the Microsoft Remote Differential Compression (RDC) library is registered on the computer specified for Configuration Manag...
     13      100 Checking Windows Installer Version >= 4.5.                                                                                                  
     14      100 Checks if the target site server computer already has existing Configuration Manager server components installed.                           
     15      100 Checks if the Windows Firewall is disabled or if a relevant Windows Firewall exception exists for SQL Server.                               
     16      100 Checks if the Windows Firewall is disabled or if a relevant Windows Firewall exception exists for SQL Server.                               
     17      100 Check SQL Server service running account.                                                                                                   
     18      100 Check to see if the selected SQL Server instance is already in use by another Configuration Manager site                                    
     19      100 Verifies that the site server's database collation matches the database collation of its parent site.                                       
     20      100 Verifies that the Microsoft .NET Framework version 3.5 is installed on Configuration Manager central administration site servers, primary...
     21      100 Checks whether the Windows Deployment Tools component of Windows Assessment and Deployment Kit (ADK) for Windows 10 is installed.           
     22      100 Checks whether the User State Migration Tool (USMT) component of Windows Assessment and Deployment Kit (ADK) for Windows 10 is installed.   
     23      100 Checks if the FQDN provided for the site system uses the primary DNS hostname for the computer.                                             
     24      100 Checks if the specified site code is already in use by another site in your hierarchy.                                                      
     25      100 Check the parent Central Administration Site has the same version.                                                                          
     26      100 Verifies that the SQL Server instance and Configuration Manager site database (if present) are configured to use a supported collation.     
     27      100 Verifies that the site server is processing critical inboxes in a timely fashion, and that inboxes do not contain files older than one day. 
     29      100 Verifies that all distribution points in the site have the latest version of software distribution packages.                                
     30      100 Verifies that the SQL Server database collation settings of the tempdb database and site database to be upgraded are the same.              
     31      100 Share Name in Package has invalid character: #.                                                                                             
     32      100 Verifies that SUM is not using any virtual locations for active SUPs.                                                                       
     33      100 Verifies that no active source hierarchy is currently configured for migration.                                                             
     34      100 Verifies that all site servers in the hierarchy meet the Configuration Manager minimum version that is required for upgrade.                
     35      100 No Active MP Replica detected                                                                                                               
     36      100 Verifies that the replication status of the parent site is Replication Active (corresponds to status=125).                                  
     37      100 Checking that the site system role 'Out of band service point' is not deployed.                                                             
     38      100 Checking whether the site system role 'System Health Validator' exists in the hierarchy.                                                    
     39      100 Checking whether there are software updates that are enabled for NAP                                                                        
     40      100 Pre-requisite rule to verify database consistency                                                                                           
     41      100 Verifies that the user account running Configuration Manager Setup has been granted sysadmin SQL Server role permissions on the SQL Serve...
     42      100 Verifies that the user account running Configuration Manager Setup has been granted sysadmin SQL Server role permissions on the SQL Serve...
     43      100 Verifies that the site server computer account has administrative rights on the SQL Server and management point.                            
     44      100 Verifies that the version of Microsoft SQL Server installed on the computer selected to host the site database meets the minimum requirem...
     45      100 Checking the site SQL Server is not Express Edition.                                                                                        
     46      100 Checking the site SQL Server Tcp is enabled and set to Static port.                                                                         
     47      100 Checks if the SQL Server hosting the Configuration Manager site database is using a case-insensitive collation.                             
     48      100 Check that the specified FQDN for the SQL Server computer is valid.                                                                         
     49      100 Check target SDK machine is not Windows Cluster Node.                                                                                       
     50      100 Checks whether the Windows Preinstallation Environment component of Windows Assessment and Deployment Kit (ADK) for Windows 10 is installed.
     51      100 Checks if SMS Provider machine has same domain as site server.                                                                              
     52      100 Checking whether there are custom Client Agent Settings that enable NAP                                                                     
     53      100 Checking whether the default Client Agent Settings enable NAP                                                                               
     54      100 Checking secondary read state of availability group replicas                                                                                
     55      100 Checking failover state of availability group replicas                                                                                      
     56      100 Checking availability group replicas for instance configuration                                                                             
     57      100 Checks if default value is set for SQL Index Create Memory                                                                                  
     58      100 Starting with version 1702, Configuration Manager does not support SQL Server 2008 R2. https://go.microsoft.com/fwlink/?linkid=841654. Th...
     59      100 Verifies that the site server operating system meets the minimum requirement of Windows Server 2008 R2 for site server installation.        
     61      100 Starting with version 1702, Configuration Manager does not support Windows Server 2008 R2 operating system. https://go.microsoft.com/fwli...
     62      100 Verifies that the site system to be upgraded meets the minimum operating system requirement of Windows Server 2008 R2 for site system ins...
     63      100 Starting with version 1702, Configuration Manager does not support Windows Server 2008 R2 operating system. https://go.microsoft.com/fwli...
     64      100 Starting with version 1702, Configuration Manager does not support Software Update Points on Loadbalancers (NLB/HLB).

Install an update and monitor its status

 
$update = Get-CMSiteUpdate -Name "Configuration Manager Technical Preview 1704" -Fast
$update | Install-CMSiteUpdate -IgnorePrerequisiteWarning -Force

while($true) {
    cls
    $update | Get-CMSiteUpdateInstallStatus -Step All -Complete | select orderid, progress, description -Last 10 | ft
    sleep 5
}

This uses the –Complete parameter for Get-CMSiteUpdateInstallStatus and only displays the completed steps. This can be useful for monitoring of long running tasks like installation.