PowerShell Script : SCCM Client Readiness Check for OS Deployment

PowerShell Script : SCCM Client Readiness Check for OS Deployment

We all know that SCCM does a great job when it comes to Operating System deployment. However, when performing OS refresh on multiple machines on LAN, you would want to check multiple things like its configuration, Operating system details and LAN/Battery Status. The script below reads the computer list from Text file and generates HTML file as Output.

The scripts checks for following:

1. Network Status – System on Wifi is not a good candidate for OS deployment

2. Battery Status – Checks if system is connected to Power source or currently running on battery

3. Existing OS details and architecture type

4. BIOS version

5. SCCM Client status – If client is installed or not and if CCMEXEC services are running

6. Hardware details like – System Model and Manufacturer, Free disk type

7. Size of Data Folder – if you have configured USMT and using hardlink for Operating System deployments, user often dump data to a location and USMT takes care of migration. The script assumes that user dump folder is “C:Safe Store” and script provides you number of folders, files and size of the folder.

Click here to download the script


Website: www.itinfrastuff.com


Gather System details that are scheduled to be upgraded to Windows 7 or Windows 8.1 using SCCM.

This script captures information information about client systems like Operating System details, BIOS Version, Network details, 
Model, Manufacturer, Memory, Battery status and status of SCCM Clients.

It is not recommended to start the Operating System refresh on SCCM clients that are connected on Wi-Fi only, or have older version of BIOS firmware.

The Script also lists if SCCM client is installe and if the service is running on it.

User Data - This scenario assumes that Users move all their necessary data to "C:Safe Store", and only this folder will be preserved by USMT during installation. 
The script checks number of folder and files in Safe Store folder and entire size of it. 

Useful to check the size before starting the migration.


Run the script and it would prompt first to enter the text (txt) file path that contains list of computers to be checked, and then
prompts to enter the location of Output file (in HTML) format.

If only file names are given in Input values, then Script invocation path is taken into consideration but file name is required as part of Input

Sample - Input File.txt

Run the script with Domain Administrator account or with account that has Administrator priviledges on client computers


#------------------------ Start of HTML formatting --------------------------- #

$style="<style>BODY{font-family: Arial; font-size: 10pt;}"
$style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}"
$style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px;}"
$style = $style + "TD{border: 1px solid black; padding:5px;}"
$style = $style + "</style>"

#---------------------- End of HTML formatting----------------------------------- #

# ----------------- Global Variables - Start ------------------------- #

$inputfile = Read-Host "Type path of the file that contains list of computers (e.g. c:Pre-Flightcomputerlist.txt) "
$outputfile = Read-Host "Output HTML file location (e.g. C:Pre-flightresult.htm) "

$list = ""
$output1 = @()
$SelectList = 'Name','Ping','Model','Version', 'LAN','WiFi','Serial','Vendor','Processor','Available Memory','Username','Domain','Architecture','BIOS Version','Safe Folders','Safe Files','Safe Size','Battery','Operating System','OS Architecture','SCCM Service','Status'
$computers = Get-Content $inputfile
$red = "<font color='#FF0000'>"
$list = "" | Select $SelectList
$pingclients = @()

# ------------------- Global Variables - End --------------------------- #

<#foreach ($comps in $computers) 
    $success = Test-Connection -ComputerName $comps -Count 1 -Quiet
    if($success -eq 'True')
        $pingclients = $pingclients + $comps
    Write-warning "$comps doesn't respond to Ping. It will not be checked further"
} #>

foreach ($comp in $computers)
	$list.Name = $comp
    $success= Test-Connection -ComputerName $comp -Count 1 -Quiet
    if($success -eq 'True')
        $list.ping = "Pass"
        $list.ping = "Failed"
        Write-Warning "$comp doesn't respond to Ping. It will not be checked further"
    <# $model = (Get-WmiObject Win32_ComputerSystem -ComputerName $comp).Model
    if ($model -eq "Virtual Machine")
        $list.model = $red + $model + $fe
        $list.model = "<td bgcolor='#FF0000'>$model</td>"
    } #>
#Capturing Windows Model and Version
    if ($list.ping -eq "Pass")
    $list.Model = (Get-WmiObject Win32_ComputerSystem -ComputerName $comp).Model
	$list.Version = (Get-WmiObject Win32_ComputerSystemProduct -ComputerName $comp).Version
    $list.Serial = (Get-WmiObject Win32_ComputerSystemProduct -ComputerName $comp).IdentifyingNumber
    $list.Vendor = (Get-WmiObject Win32_ComputerSystemProduct -ComputerName $comp).Vendor
    $list.username = (Get-WmiObject Win32_ComputerSystem -ComputerName $comp).username
    $list.domain = (Get-WmiObject Win32_ComputerSystem -ComputerName $comp).domain
    $list.Processor = (Get-WmiObject Win32_Processor -ComputerName $comp).Name
    $list.architecture = (Get-WmiObject Win32_ComputerSystem -ComputerName $comp).SystemType
    $calculation = (Get-WmiObject Win32_ComputerSystem -ComputerName $comp).TotalPhysicalMemory
    $calculation = [math]:: truncate($calculation / 1MB)
    $list.'Available Memory' = $calculation.tostring() + " MB"
    $list.'BIOS Version' = (Get-WmiObject Win32_BIOS -ComputerName $comp).SMBIOSBIOSVersion
    #$list."available memory" = ((Get-WmiObject Win32_ComputerSystem -ComputerName $comp).TotalPhysicalMemory / 1MB).tostring() + " MB"

#Capturing Safe Store Details
    $list.'Safe Folders' = (Get-ChildItem "$($comp)C$Safe Store" -Recurse | where{$_.PSisContainer -eq 'True'}).count
    $list.'Safe Files' = (Get-ChildItem "$($comp)C$Safe Store" -Recurse | where{$_.PSisContainer -ne 'True'}).count
    $Z = 0
    Get-ChildItem "$($comp)C$Safe Store" -Recurse | foreach{$Z+=$_.length}
    $safesizetotal = [math]:: round($Z / 1MB,2)
    $list.'Safe Size' = $safesizetotal.ToString() + " MB"
#Battery Details
    $BatteryStatus = Get-WmiObject Win32_battery -ComputerName $comp | select BatteryStatus
    If ($BatteryStatus.batterystatus -eq 1)
        $list.battery = "Unplugged"
    if ($BatteryStatus.batterystatus -eq 2)
        $list.battery = "Charging"
        $list.battery = "Desktop"

#Capturing Network details
    $Network = Get-WmiObject Win32_NetworkAdapter -ComputerName $comp | where{$_.NetConnectionStatus -eq 2} | Select NetConnectionID, NetConnectionStatus
    if($Network -eq $Null)
        $list.LAN = "Undetermined"
        $list.Wifi = "Undetermined"
    foreach($Net in $Network)
        if($Net.NetConnectionID.Contains("Local Area Connection"))   
            $list.LAN = "True"
            $list.LAN = "True"
            $list.LAN = "Virtual NIC Active"
            $list.Wifi = "True"
            $list.WiFi = "False"

    $list.'Operating System' = (Get-WmiObject Win32_OperatingSystem -ComputerName $comp).Caption
    $list.'OS Architecture' = (Get-WmiObject Win32_OperatingSystem -ComputerName $comp).OSArchitecture
    $checksccmservice = Get-WmiObject Win32_Service -ComputerName $comp -Filter{Name='CCMEXEC'} | select Name,State
    If($checksccmservice.Name -eq $Null)
            $list.'SCCM Service' = "Not Installed"
    If($checksccmservice.Name -eq 'CCMEXEC')
            $list.'SCCM Service' = "Installed"
     If($checksccmservice.State -eq $Null)
            $list.status = "Undetermined"
    IF($checksccmservice.State -eq 'Running')
            $list.status = "Started"
        $list.Architecture = "Skipped"
        $list.'Available Memory' = "Skipped"
        $list.Battery = "Skipped"
        $list.'BIOS Version' = "Skipped"
        $list.Domain = "Skipped"
        $list.LAN = "Skipped"
        $list.Model = "Skipped"
        $list.'Operating System' = "Skipped"
        $list.'OS Architecture' = "Skipped"
        $list.'Safe Files' = "Skipped"
        $list.'Safe Folders' = "Skipped"
        $list.'Safe Size' = "Skipped"
        $list.'SCCM Service' = "Skipped"
        $list.Serial = "Skipped"
        $list.Status = "Skipped"
        $list.Username = "Skipped"
        $list.Vendor = "Skipped"
        $list.Version = "Skipped"
        $list.WiFi = "Skipped"
        $list.Processor = "Skipped"

    #$output1 = "" | Select 'Name','Model','Version'
	$output1 += $list | Select $SelectList
$output1 = $output1 | sort Name
#Write-host $output1

$output2 = $output1 | ConvertTo-Html -Head $style

$output2 > $outputfile
Invoke-Item $outputfile





About The Author

Related posts

1 Comment

  1. Chris Merz

    Created a list of serves and tried running it: got the following error message:

    Type path of the file that contains list of computers (e.g. c:Pre-Flightcomputerlist.txt) : c:check-sccmservers.txt
    Output HTML file location (e.g. C:Pre-flightresult.htm) : c:check-sccmreportsd.htm
    Get-ChildItem : An unexpected network error occurred.
    At C:check-sccmSCCM_Check.ps1:118 char:29
    + $list.’Safe Folders’ = (Get-ChildItem “\$($comp)C$Safe Store” -Recurse | …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ReadError: (\ITX1036BC$W…esWMIRtBackup:String) [Get-ChildItem], IOException
    + FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand


Leave a Reply

Your email address will not be published. Required fields are marked *