Saturday, 23 June 2012

Checking BITs health on SCCM site servers with PowerShell

On a number of occasions I discovered that the BITs configuration in IIS has become corrupt resulting in SCCM agents being unable to submit new software and\or hardware inventory. There are no errors reported in any client logs, in fact the client logs give the impression that the MIF files were submitted to the site server successfully. If you enable IIS logging on the site server you will see error 501 log entries appear. This issue can also be confirmed by trying to view the BITs settings for the default website in IIS. The purpose of this script is to assist in easy identification of MP's where BITs is broken.

How to manually check BITs on an MP with PowerShell command:
  1. Open PowerShell as an administrator from the start-menu.
  2. Start-BitsTransfer -source .\Test-Bits.txt -dest http://[SCCMServerMP]/CCM_Incoming/test-bits.txt -TransferType Upload

Note: The above command requires a text file created locally which can be copied to the site server. If BITs is broken on the SCCM site server then the transfer will fail. You should manually delete the copied text file from the CCM_Incoming folder on the site server after the test is complete.

How to check multiple MP's with a PowerShell script:
  1. Copy the script to any local folder.
  2. Open PowerShell  as an administrator from the start-menu.
  3. Type ‘Set-executionpolicy remotelysigned’ and agree to prompt with 'Y’
  4. Run the script from any location using an explicit path.
                  e.g. ‘help .\Test-SCCMBitsTransfer.ps1  -full' to view syntax examples.

Note: To view script information and syntax type in the PowerShell shell:
              'help  Test-SCCMBitsTransfer.ps1 -full

Solution to a broken BITs client on a MP (link)
Fix MP fails to re-install on a site Reset
501 Errors found in IIS logs: 
Error seen in IIS when checking BITs settings:
Running the PowerShell Script:


PowerShell Script: Test-SCCMBitsTransfer.ps1
https://docs.google.com/open?id=0B2PiqIWBY0KsT2ZjMkZZMmxnZ1E

Below are links to a couple of my other blog posts that describe the method I would recommend to correct management point or BITs errors.

Fix MP fails to re-install on a site Reset
http://www.blogger.com/blogger.g?blogID=3820049899844331410#editor/target=post;postID=9068478152764659215


SCCM - Unable to enable BITs on an IIS virtual directory.
http://www.blogger.com/blogger.g?blogID=3820049899844331410#editor/target=post;postID=4941805560145335979







SCCM - Unable to enable BITs on an IIS virtual directory.


As a result of an issue I encountered recently with an SCCM 2007 primary site server it should be noted that if BITs cannot be enabled on IIS virtual directories then the following additional steps should be used prior to the reboot. The issue I was working with started out as investigating why SCCM client hardware inventory was not being recorded on site server. In the end it was found to be that because BITs on the server was corrupt it resulted in SCCM agents being unable to upload inventory MIF files.

1. Run ccmdelcert.exe from the SMS 2003 resource kit to remove SCCM related certificates.
2. Delete the contents of the following folders:
"C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\S-1-5-18\".
"C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys".
3. Reboot
4. Create a test IIS virtual directory and enable BITs transfers to confirm IIS can use BITs successfully.

Related Web Articles:
You receive error message 0x80090016 or error message 0x8009000f when you try to schedule a task
http://support.microsoft.com/kb/246183
Quote:
“6. Delete all of the files in the "C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\S-1-5-18" folder.
7. Reboot”

0x80090016: Keyset does not exist
http://chandusb1.blogspot.com.au/2011/03/0x80090016-keyset-does-not-exist.html

Fix MP fails to re-install on a site Reset

Issue:
The MP installation failed on the site server after the a site reset with provider was performed.

Analysis and solution:
The following errors were recorded in the mpMSI.log on the site server when attempting to install\reinstall the management point.

MSI (s) (AC!CC) [09:41:17:095]: Product: SMS Management Point -- Error 25006. Setup was unable to create the Internet virtual directory CCM_Incoming
The error code is 800CC801


Error 25006. Setup was unable to create the Internet virtual directory CCM_Incoming
The error code is 800CC801
CustomAction CcmCreateIISVirtualDirectories returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
MSI (s) (AC:64) [09:41:17:114]: User policy value 'DisableRollback' is 0
MSI (s) (AC:64) [09:41:17:114]: Machine policy value 'DisableRollback' is 0
Action ended 9:41:17: InstallFinalize. Return value 3.

Perhaps due to a previous SMS agent host service crash and server unexpected shutdown, the BITs extension may be corrupted on the site server. This also prevents a MP being re-installed and would also prevent clients successfully reporting updates compliance.

Performing  the below actions fixed the issue:
1. Uninstall the failed MP role from the SCCM console
2. Uninstall the SCCM agent from the site server.
3. Remove the BITs feature from the Server Manager console.
4. Reboot the server.
5. Install the Windows BITs feature.
6. Install the MP - This time it should install successfully.
7. Install the SCCM agent.
  • Afterwards the clients were able to communicate properly with the MP, receive policy and report updates compliance status
  • Please note: This is also a fix for some obscure client policy or client updates compliance issues or any situation where Bits may be suspect.
  • Also please note: The MP appeared to be healthy according to MP control log prior to attempting the site reset with 200 (healthy) status.
  • This remediation process is what I follow any time there is any recurring issues with a site servers management point or SCCM agent. 


Monday, 18 June 2012

PowerShell Script to copy and verify smsdef.mof files.

In an effort to simply the tedious task of updating the MOF files on SCCM site servers I have written a PowerShell script which will perform a MD5 HASH comparison of your MOF file between the target server and its child servers. The script will use a SQL query to determine the child site server list and their install folders. When the file HASHes being compared differ you will be prompted to overwrite the incorrect file with the file from the target server. The output of the script is a table displaying all the file HASHes generated for visual comparison. If you choose to overwrite any files be sure to run the script a second time to re-check all the file HASHes. By default the script only checks the SMS_DEF.MOF, an alternate filename can be specified with the '-MOFFile' parameter. Full help and syntax examples can be seen by running the help option below. Any feedback or suggestions are always appreciated.

Steps:
1. Copy the script to any local folder.
2. Open PowerShell with your Admin account from the startmenu.
3. Type ‘Set-executionpolicy RemoteSigned’ and agree to prompt with 'Y’
4. Run the script from any location using an explicit path.
                  e.g. ‘help .\SCCM_MOF_Replicate.ps1 -full' to view syntax examples.

Note: To view script information and syntax type 'help SCCM_MOF_Replicate.ps1 -full'

Running the script:

PowerShell Script:
https://docs.google.com/open?id=0B2PiqIWBY0KsSnZRVXhNNVRGajA

Sunday, 17 June 2012

PowerShell - Scripted Install of SCCM site server prerequisites


To reduce the time it takes to provision a 2008 SCCM site server I have improved on another internet sourced PowerShell script to automate all the set-up steps detailed in the TechNet article linked below.

How to Configure Windows Server 2008 for Configuration Manager 2007 Site Systems
http://technet.microsoft.com/en-us/library/cc431377.aspx

PowerShell Script:
https://docs.google.com/open?id=0B2PiqIWBY0KsWlAzVnd3MGJHUWM

Run Steps:
  1. Copy the script a local folder.
  2. Open PowerShell as an Administrator from the start menu.
  3. Type ‘Set-ExecutionPolicy RemoteSigned’ and agree to prompt with ‘Y’
  4. Run the script from any location using an explicit path. 
i.e. ‘.\Install_SCCM_Pre-Reqs.ps1’ if run from the current folder.


Install progress display output when run on a new 2008 server.
 

Script output when rerun subsequent times:

Friday, 15 June 2012

How to delete orphaned & locked SCCM folders

Description:
You are unable to delete orphaned locked console folders on a mid tier site that is also not visible at its parent site.

Analysis and solution:
A "locked" object in SCCM means that the object was created on a parent site so cannot be edited at a child primary site as indicated by a padlock on the console object. This is determined by the SourceSite value for the CI in the SCCM database at each primary site in the hierarchy.

For orphaned CI's that are not visible at its parent site, it is possible to manually set their SourceSite value to the site code where the CI is visible. It can then be modified\deleted in the console.

How to 'unlock' a CI in the SCCM database:
1. Perform a successful SCCM site backup.

2. Use the following SQL commands to update the folder CI in the database with the site code for the current site. This will 'unlock' the CI and allow it to be deleted or modify it in the console. Any changes made to the newly unlocked CI should replicate to child primary sites.

Declare @FolderName varchar( 32 )
Set @FolderName = 'My App Folder'
Declare @ParentSite varchar( 32 )
Set @ParentSite = 'ABC'


-- Before updating parent site code.
Select * from Folders where Name = @FolderName and ParentContainerNodeID = '0'
-- Updating parent side code.
-- Update Folders
-- Set SourceSite = @ParentSite --effected child primary site code
-- Where Name = @FolderName --effected folder name here
--and ParentContainerNodeID = '0' -- Effects only folders in the console root.
--After updating parent site code.
Select * from Folders where Name = @FolderName and ParentContainerNodeID = '0'

If the wrong CI is updated that does exist at a parent site then the next time any change is made to the parent CI  then the CI's all child primary sites will be updated to mirror the top level CI.

Note: Modifying the SCCM site database is totally unsupported by Microsoft and you are taking your life in your own hands by doing so. This information is for reference only and should not be used without direct consultation with Microsoft Premier Support Services.


How to confirm software update supersedence\ expiry information outside of the SCCM console


Scenario:
Five KB's for bulletin MS10-087 could not be found in the SCCM software updates repository however they could be seen in the WSUS console on the SCCM ASUP. The updates found in the WSUS console did not clearly indicate that they were superseded and this cause confusion with operational teams. Initial investigation pointed to the updates for MS10-087 were not being sync'ed into the SCCM repository for an unknown reason.

Solution:
Through checking the Microsoft Update Catalog website it was confirmed that MS10-087 had been superseded by a number of later updates that were being actively deployed. The reason for the five MS10-087 updates missing from the SCCM repository was that some time ago the repository was recreated due to database corruption. At the time of the first sync with Microsoft windows update MS10-087 was already superseded so was excluded from the sync process.

Superseded updates will not be synced into the SCCM repository if the update CI doesn't already exist, if the CI does exist the sync process will update the database record to mark it as superseded. Superseded updates will not automatically be removed from the SCCM repository, they will just accumulate over time.

Expired updates will not be synced into the SCCM repository if the CI doesn't already exist, if the CI does exist it will update the database record to mark it as expired. The point of difference is expired updates will automatically be deleted from the SCCM repository 7 days after their state has changed to expired in the database. It is important to remove any expired updates from update lists, package and deployments to avoid orphaned database entries otherwise software updates CI replication to child sites could break.

How to check the status of an update on-line:

1. Open the Microsoft Update Catalog : http://catalog.update.microsoft.com

2. In the right corner you can input the bulletin ID (such as : MS10-087)

3. Click Search and you will got the updates return.

4. Click on Security Update for Microsoft Office XP (KB2289169)

5. Click on the Package Details, you can then view the supersedence information for this update.

Thursday, 14 June 2012

PowerShell - Get drive statistics WIN32_LogicalDisk

PowerShell Command
Get-wmiobject -computername $ServerName win32_logicaldisk -filter "drivetype='3'" | select @{Name="Computer Name";expression={$_.SystemName}},@{Name="Drive";expression={$_.deviceID}},@{Name="Volume Name";expression={$_.VolumeName}} ,@{Name="Free(GB)";expression={[math]::truncate($_.freespace/1.0GB)}},@{Name="% Free";Expression={[math]::truncate(($_.FreeSpace/$_.Size)*100)}}, @{Name="Total(GB)";expression={[math]::truncate($_.Size/1.0GB)}} | format-table -autosize


Note: Substitute 'localhost' with a remote system you want drive information for.


I have actually added the command line as a function into a .psm1 module file on our management server and  then published the Powershell console through RDS so others can benefit from this tool among others I have created. I would highly recommend others consider adding any Powershell 'tools' they create into a module on a terminal server and then publish the shell for others to use. I have found this to be a particularly useful approach in a large organisation.


File Path:
C:\Windows\System32\WindowsPowerShell\v1.0\Modules\SCCM\SCCM.psm1



function Get-SCCMDriveSpace {

    [CmdletBinding()]
    PARAM
    (
        [Parameter(Mandatory=$true, HelpMessage="SCCM Site Server",ValueFromPipeline=$true)] $ServerName
    )   
            Get-wmiobject -computername $ServerName win32_logicaldisk -filter "drivetype='3'" | select @{Name="Computer Name";expression={$_.SystemName}},@{Name="Drive";expression={$_.deviceID}},@{Name="Volume Name";expression={$_.VolumeName}} ,@{Name="Free(GB)";expression={[math]::truncate($_.freespace/1.0GB)}},@{Name="% Free";Expression={[math]::truncate(($_.FreeSpace/$_.Size)*100)}}, @{Name="Total(GB)";expression={[math]::truncate($_.Size/1.0GB)}} | format-table -autosize
 }

Note: I have named this function SCCM so as to group it in Powershell help results with other SCCM Powershell tools that have been created for the support teams.

Monday, 11 June 2012

Remotely search ARP for SCCM hotfixes with PowerShell

Here is a quick PS command I created to search a remote SCCM site server to check which hotfixes we had already installed. In this instance I was just reviewing a single server however it could easily be extended by first reading a list of server names from a text file with the get-content cmdlet.


Get-wmiobject -computername server01 -Class SMS_InstalledSoftware -namespace root\cimv2\sms | where {$_.ARPDisplayName -like "*configmgr*"} | format-wide



Saturday, 9 June 2012

MP Reg: Failed to get client(GUID:) public key: 0x80040238

Recently I thought I had an issue with SCCM clients being unable to register normally when initially installed. I had noticed the following error in the MP_RegistrationManager.log on the site server with the management point role installed and could not find any information on the web discussing this particular error. As a result I opened a case with Microsoft PSS and was informed that 0x80040238 can be safely ignored because it just represents a temporary status when a new client is trying to register. When a MP receives a new client registration request it will try to match the client public certificate hash (mixed or native mode environments)  to any already known in the database as a means of matching to an existing resource record. If there is no existing resource record with the same hash to match with then the following error will be recorded temporarily until the registration process is completed and a new resource record is created. Unfortunatily without verbose agent logging enabled you do not see the entire process including success entries in the mp_registrationmanager.log, only the error messages.


MP_RegistrationManager.log Error:
MP Reg: Failed to get client(GUID:) public key: 0x80040238


0x80040238 simply means the public key is not found. This error will almost always be reported when a new client is trying to register itself. Because the client is new, it is normal that no public key exists in the ClientKeyData table for that client. It is after that error is reported that the registration happens.

For example, here is a MP_RegistrationManager.log displaying successful registration where verbose agent logging has been enabled on the SCCM site server:

We can see the 0x80040238 error is just informational, as long as a second “Confirmation” of “ClientRegistrationResponse” can be received by the client. Here’s what the client’s ClientIDManagerStartup.log says at the same time:

Reference:How to enable verbose logging for the SCCM Agent.


How to enable verbose logging for the SCCM Agent.


A very effective way to expose more detailed information within the SCCM agent logs on both clients or site servers is to modify the below registry keys. As a bonus if you do this on an SCCM site server with the MP role installed then you will also see verbose logging within management point logs. This is due to the MP being integrated with the SCCM agent so this is why verbose agent logging also affects the MP logs. This can be extremely useful for when troubleshooting management point errors. As a real world example I used this technique to monitor when exactly client registrations were occurring on a management point in the mp_registrationmanger.log as by default it will only show errors. Setting the following registry keys will only enable verbose logging for the SCCM agent and not affect other site server logs when performed on an SCCM site server.

Steps to enable verbose logging for the SCCM Agent:

a) Modify the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\CCM\LOGGING\@GLOBAL\LogLevel value from 1 to 0, LogMaxSize to 5000000 (decimal, 5MB) and LogMaxHistory to 4.
By default, Administrators have no permission to modify this value. You may need to grant you admin account full control rights first.
b) Create HKLM\Software\Microsoft\CCM\Logging\DebugLogging as a key. Don’t need to create any values under the key.
c)Restart 'SMS Agent Host' service (CCMExec).

Note: Only leave the verbose logging enabled for the duration of your troubleshooting.

Fig 1. Changing registry permissions before editing keys:

The above log settings will only affect SCCM Agent logs contained within the following paths:

  • x86 C:\Windows\System32\CCM\Logs\
  • x64 C:\Windows\SysWow64\CCM\Logs\






Friday, 8 June 2012

SCCM database column widths and failed HWInv processing.


Recently I had to work on an issue were database column width expansion errors had been noted in both the SMS_INVENTORY_DATA_LOADER site component status messages and the dataldr.log when a primary site server is attempting to process hardware inventory MIF's from some clients. When agents submit new hardware inventory that contains data which is longer than the current database table column width a column width expansion request will be triggered. If the maximum column width value in the database is lower than the expansion value then hardware inventory processing for the MIF will fail. The root cause of this is the site server database was originally created as an SMS 2003 site server which had previously been upgraded to SCCM 2007 and at which time the database maximum column width values were not automatically increased to the 2007 defaults. After getting in contact with Microsoft PSS support it was discovered this is a known issue that the MaxColWidth value in the AttributeMap table is smaller than the actual column width in the corresponding DATA table. This could be due to some failed upgrade / installation of the site, which might have modified either value but not the other.

This issue was manually fixed by correcting the MaxColWidth value, in which case we prevented automatic widening from being triggered incorrectly. There is no need to drop any indexes on the columns after updating the column widths.

In most cases automatic widening will be able to fix the inconsistent AttributeMap, MaxColWidth and CHARACTER_MAXIMUM_LENGTH when the actual width of the attribute in the MIF exceeds MaxColWidth. The only problem of this inconsistency happens to the columns on which the DATA tables (e.g., INSTALLED_SOFTWARE_DATA) have non-clustered index depending on those columns and blocking automatic widening (incorrectly triggered due to the inconsistency).

Error Status Messages:
*** ALTER TABLE dbo.INSTALLED_SOFTWARE_MS_DATA ALTER COLUMN SoftwareCode00 varchar(72)  NULL                SMS_INVENTORY_DATA_LOADER           5/30/2012 7:33:19 PM    1544 (0x0608)
*** [42000][5074][Microsoft][ODBC SQL Server Driver][SQL Server]The index 'sw_ms_data_idx2' is dependent on column 'SoftwareCode00'.           SMS_INVENTORY_DATA_LOADER           5/30/2012 7:33:19 PM    1544 (0x0608)
*** ALTER TABLE dbo.INSTALLED_SOFTWARE_MS_DATA ALTER COLUMN SoftwareCode00 varchar(72)  NULL                SMS_INVENTORY_DATA_LOADER           5/30/2012 7:33:19 PM    1544 (0x0608)
*** [42000][4922][Microsoft][ODBC SQL Server Driver][SQL Server]ALTER TABLE ALTER COLUMN SoftwareCode00 failed because one or more objects access this column.             SMS_INVENTORY_DATA_LOADER           5/30/2012 7:33:19 PM    1544 (0x0608)
CDefinedGroup::WidenDefinedAttribute - could not change data type. SMS_INVENTORY_DATA_LOADER           5/30/2012 7:33:19 PM          1544 (0x0608)
CGroup::DefineAttributes - unable to widen attributes  SMS_INVENTORY_DATA_LOADER           5/30/2012 7:33:19 PM    1544 (0x0608)


 Example Scenario:
1. The MIF processing problem happens when data loader is trying to widen the CM_DSLID attribute.
2. Automatic widening happens when the AttributeMap.MaxColWidth value is less than the actual attribute width in the MIF, and it will attempt to set both MaxColWidth and the actual column width of the DATA table (INSTALLED_SOFTWARE_DATA.CM_DSLID00) to the smallest mod-8 number that is enough to hold the MIF attribute.
3. However, there’s a non-clustered index “sw_data_idx2” on the INSTALLED_SOFTWARE_DATA table that includes the column “CM_DSLID00”, so that automatic column widening failed in the ALTER TABLE attempt.
4. As the INSTALLED_SOFTWARE_DATA.CM_DSLID00 column is already of the correct width (255), we can simply modify the AttributeMap.MaxColWidth value to 255 to prevent this from happening again.
  

Errors as seen in the dataldr.log
Note the difference between an upgraded 2003\2007 site server in column 1 versus the values from a native SCCM 2007 database.


The following are the SQL commands used to update the SCCM database on the site server reporting errors. These commands are to be used at your own risk and you would be taking you life into your own hands without a current backup! 

Table - 'Installed_Software_MS_Data'

Note: Run the first select query in each block to check the current values within the database to check the database even needs updating BEFORE uncommenting and running the proceeding update statements.

Select ColumnName, MaxColWidth, GroupKey From AttributeMap Where GroupKey In ( Select GroupKey From GroupMap Where SpecificTableName = 'Installed_Software_MS_Data' ) order by ColumnName

--Update AttributeMap Set MaxColWidth = 16 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_MS_Data' ) AND ColumnName = 'ChannelCode00'
--Update AttributeMap Set MaxColWidth = 16 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_MS_Data' ) AND ColumnName = 'ChannelID00'
--Update AttributeMap Set MaxColWidth = 16 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_MS_Data' ) AND ColumnName = 'MPC00'
--Update AttributeMap Set MaxColWidth = 255 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_MS_Data' ) AND ColumnName = 'ProductCode00'
--Update AttributeMap Set MaxColWidth = 255 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_MS_Data' ) AND ColumnName = 'SoftwareCode00'
--Select ColumnName, MaxColWidth, GroupKey From AttributeMap Where GroupKey In ( Select GroupKey From GroupMap Where SpecificTableName = 'Installed_Software_MS_Data' ) order by ColumnName

Table - 'Installed_Software_Data'

Select ColumnName, MaxColWidth, GroupKey From AttributeMap Where GroupKey In ( Select GroupKey From GroupMap Where SpecificTableName = 'Installed_Software_Data' ) order by columnname

--Update AttributeMap Set MaxColWidth = 255 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_Data' ) AND ColumnName = 'ARPDisplayName00'
--Update AttributeMap Set MaxColWidth = 255 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_Data' ) AND ColumnName = 'CM_DSLID00'
--Update AttributeMap Set MaxColWidth = 255 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_Data' ) AND ColumnName = 'InstalledLocation00'
--Update AttributeMap Set MaxColWidth = 255 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_Data' ) AND ColumnName = 'LocalPackage00'
--Update AttributeMap Set MaxColWidth = 255 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_Data' ) AND ColumnName = 'ProductName00'
--Update AttributeMap Set MaxColWidth = 255 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_Data' ) AND ColumnName = 'Publisher00'
--Update AttributeMap Set MaxColWidth = 255 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_Data' ) AND ColumnName = 'RegisteredUser00'
--Update AttributeMap Set MaxColWidth = 48 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_Data' ) AND ColumnName = 'SoftwarePropertiesHash00'
--Update AttributeMap Set MaxColWidth = 48 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_Data' ) AND ColumnName = 'SoftwarePropertiesHashEx00'
--Update AttributeMap Set MaxColWidth = 48 Where GroupKey= (Select GroupKey from GroupMap Where SpecificTableName = 'Installed_Software_Data' ) AND ColumnName = 'UpgradeCode00'
--Select ColumnName, MaxColWidth, GroupKey From AttributeMap Where GroupKey In ( Select GroupKey From GroupMap Where SpecificTableName = 'Installed_Software_Data' ) order by columnname

Cheers

Ben

Thursday, 7 June 2012

PowerShell - Enable \ Disable Automatic Updates


Hi All,

As this is my first ever blog post so I thought I would try something short and simple. Today I got asked how can the automatic updates agent be disabled as a scripted action with PowerShell. After a bit of research I found that it can easily be controlled through a native COM object. I have not included any script in this post, I just wanted to show how easy it is to do from the command line. These commands could easily dropped into a .ps1 along with any other required smarts.

PowerShell Commands Used:


Record the WUAU settings into an object
PS C:\> $AUSettigns = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
View the object properties
PS C:\> $AUSettigns
Change the property value
PS C:\> $AUSettigns.NotificationLevel = 4
Commit the changes back to the system.
PS C:\> $AUSettigns.Save


Disabling Automatic Updates

 Enabling Automatic Updates:



Thanks,

Ben