2009/12/23

Delete the WSUS Client ID's from registry by Powershell script

CURRENT CONFIGURATION: Microsoft Windows 2003 with Powershell 1.0; WSUS 3; OS distribution method is cloning (imaging) of computers or virtual machines copying.
OBJECTIVE: Fix the issue with computer name overlapping in WSUS
ISSUE: Computers override each other or not appear in WSUS console.
SOLUTION: When you clone (re-image) new computer from different either disk or clone image WSUS Client ID would be the same for either both or all recloned (reimaged) computers.
I wrote Powershell script to delete WSUS client ID's in registry.
DeleteWSUSid.ps1
# *****************************************************************************
# Windows Powershell script
# Author:  Vadim Zenin http://vadimszenins.blogspot.com
# Version:  1.00
# Date:     27/11/2009 13:47:06
# Purpose: Delete the WSUS Client ID's from the registry.
#
# Do not forget: Set-ExecutionPolicy RemoteSigned
#
# Arguments:
#
# Tested platform:
# Windows Powershell v 1.0,
# Windows 2003 R2 x64 SP2
#
# Version 1.00 revision:
#
# This code is made available as is, without warranty of any kind. The entire
# risk of the use or the results from the use of this code remains with the user.
# *****************************************************************************

Param(
)

# Require
# =============================================================================

# =============================================================================
# Function that returns true if the incoming argument is a help request
# =============================================================================
function IsHelpRequest
{
    param($argument)
    return ($argument -eq "-?" -or $argument -eq "-help");
}

# =============================================================================
# Function: Get-Usage
# Author: Vadim Zenin
# Created: 30/10/2009 13:01:21
# Purpose: Script usage explanation and examples.
# Arguments: none
# Returns:
# =============================================================================
function Get-Usage()
{
@"

USAGE:

NAME:
$ScriptNameOnly.ps1

SYNOPSIS:
Delete the WSUS Client ID's from the registry.

PARAMETERS:

EXAMPLES:
.\$ScriptNameOnly.ps1

"@
}

# =============================================================================
#  MAIN SCRIPT
# =============================================================================

$ScriptPath = $MyInvocation.MyCommand.Path
$ScriptNameOnly = [system.io.path]::GetFilenameWithoutExtension($ScriptPath)
#write-host " ScriptNameOnly: $ScriptNameOnly"

# Check for Usage Statement Request
$args | foreach { if (IsHelpRequest $_) { Get-Usage; exit; } }

write-host "Deleting the WSUS Client ID's from the registry"
$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate"
$RegProperties = "AccountDomainSid", "PingID", "SusClientId", "SusClientIdValidation"
foreach ($RegProperty in $RegProperties) {
    remove-itemproperty -path $RegPath -name $RegProperty -erroraction silentlycontinue
}
#Get-ItemProperty $RegPath

Write-Host -ForegroundColor DarkGreen " Script $ScriptNameOnly has finished"
Download md5: 1bdfcbd25c3b78d204110ace9d89bb8e

Комментариев нет: