VBScript: Cleanup all computer objects for local PC

Download “CleanupLocalPCMac-1.0.zip” CleanupLocalPCMac-1.0.zip – Downloaded 311 times – 2 KB

When we are deploying OS via ConfigMgr, we usually do a cleanup of all old objects before creating the new object.

This helps prevent errors and mistakes, and is pretty easy to do.

We are able to use both SMBOIS GUID and Mac addresses for the cleanup.

usually I recommend using mac addresses, since I have experienced that laptops who have had their mainboard exchanged, have the BIOS GUID of “0000-00000-0000-0000”, this happens because the repair shop forgets to write in the GUID after the repair.

The mac addresses are always usable , since they are not typed in by hand.

Problem by using the mac adresses is that there is more than on each, therefore I have made this script that does a cleanup of All computer objects in the SCCM, checking for All of the Mac Addresses.

This script can be used of difference purposes.

1. Trobuleshooting. if you are having problems with the configmgr account of a specific PC. Run this script on the PC, and the configmgr will be cleaned up, which might solve your problems.

2. Deployment. Run this script in WinPE as a part of new deployment of an already exiting PC, to make sure that all old objects are gone, before reinstalling.

 

About the Author:

Jakob Gottlieb Svendsen

Twitter: @JakobGSvendsen

Jakob Gottlieb Svendsen is a Microsoft Cloud and Data Center Management MVP (http://mvp.microsoft.com/en-us/default.aspx), Working as Global Lead Developer, Senior Consultant and Trainer at CTGlobal, where he is one of the driving forces in keeping CTGlobal a System Center Gold Partner and member of the System Center Alliance.

Since he started at Coretech in 2007, he has focused on Scripting and Development, primarily developing tools, extensions and scripts for the System Center Suite. His main area is Automation (including OMS/Azure Automation, Service Management Automation, PowerShell and Orchestrator). Another area is Windows Azure Pack / Azure Stack, where he does implementation, development, workshops and presentations. He is a world-wide renowned voice in the Automation field.

He is passionately devoted to the community, to which he contributes by being a moderator at TechNet and sharing his knowledge at https://blog.ctglobalservices.com/jgs

  • Co-founder: PowerShell User Group Denmark
  • Speaker at MMS 2016, Minneapolis (www.mmsmoa.com)
  • SCU Europe 2014, 2015, 2016 (www.systemcenteruniverse.ch)
  • Microsoft TechEd North America 2014, Houston
  • NIC 2012,2013,2014,2015, Oslo (www.nic.com)
  • Microsoft CampusDays 2011, 2013, Copenhagen
  • Microsoft TechDays 2015, Sweden (www.techdays.se)
  • Microsoft Partner Event: New in SC2012 SP1
  • User group meetings (PSUG.DK , SCUG.DK/BE/NO, AZMUG + more)
  • Microsoft Certified Trainer.
  • Microsoft Scripting Guys Forum Moderator

Main working areas:

  • Automation (Azure Automation, SMA, SCO)
  • Windows Azure Pack / Azure Stack
  • System CenterVisual Studio Team Services / Team Foundation Server
  • Development:C#.Net, VB.NET, VBScript, PowerShell, Service Manager, OpsMgr, ConfigMgr
  • Orchestrator
  • Windows Azure Pack / Azure Stack

Training:

  • Azure Automation
  • Service Management Automation
  • System Center Orchestrator
  • PowerShell, VBScript, C#.Net, VB.Net
  • Windows Azure Pack / Azure Stack Development Workshops

2 Comments

  1. Fabian April 13, 2012 at 11:02 - Reply

    Hello,

    I have a Win7 x64 System here and it seems script doesnt work there:

    Script started: 13.04.2012 10:30:27
    Connection to local ConfigMgr etablished
    Checking for old computer objects via Mac and GUID…
    Skpping adapter: [00000000] WAN Miniport (SSTP) – no mac address
    Skpping adapter: [00000001] WAN Miniport (IKEv2) – no mac address
    Skpping adapter: [00000002] WAN Miniport (L2TP) – no mac address
    Skpping adapter: [00000003] WAN Miniport (PPTP) – no mac address
    Skpping adapter: [00000004] WAN Miniport (PPPOE) – no mac address
    Skpping adapter: [00000005] WAN Miniport (IPv6) – no mac address
    Skpping adapter: [00000006] WAN Miniport (Network Monitor) – no mac address
    Skpping adapter: [00000007] Intel(R) 82566DM-2 Gigabit Network Connection – no mac address
    Skpping adapter: [00000008] WAN Miniport (IP) – no mac address
    Skpping adapter: [00000009] Microsoft ISATAP Adapter – no mac address
    Skpping adapter: [00000010] RAS Async Adapter – no mac address
    Skpping adapter: [00000011] Intel(R) PRO/100 S Desktop Adapter – no mac address
    Skpping adapter: [00000012] Intel(R) PRO/100 S Desktop Adapter – no mac address
    Script End

    Any idea?

    Thanks for your help!

  2. danny November 14, 2012 at 0:08 - Reply

    I tried this to but worked allright for me, except of some registery errors I get when trying to update some modules.
    The Blue screen still pops up when I start my pc.
    After trying almost everything I downloaded Fix my PC and everything is as new.
    You can read more here http://tinyurl.com/boogyej.

Leave A Comment