Image Validation Script used in TS execution, OSD validation

Hello Friends,

As a build administrator, post Operating system deployment, Image Validation is a very very important task. There are multiple parameters we have to check post OS installation.
Like, we have to check each and every application installed on the machine and also check the version of each application, whether it's installed correctly or not?

We have to check whatever the patches we have targeted to the device are installed properly or not?

Sometimes we are getting requirements from clients saying that we have to set some services in disabled mode and some services we need to set as an automatic start. These services' startup type and status should be the same as we configured before executing Task Sequence or while capturing the WIM file.

Manual drivers validation is again a very difficult task, why not capture all the drivers installed on the machine and save it in the same CSV file for further validation.
Here we have created one PowerShell script which we can run manually on a single machine or we can add the same script into the Task Sequence as well.

Adding the script in Task Sequence will reduce the effort to run it manually and we can collect the CSV file directly from location "C:\Windows\CCM\Logs\$hostnames.csv". 

The script output in the CSV file will be display as shown in the below image.

Get the installed apps, Drivers, patches, services from single machine

<#

    .SYNOPSIS

    Image Validation Script used in TS execution, OSD checklist validation

    .DESCRIPTION

    This script will validate the installed services, applications, patches, Drivers and other system info

    .NOTES

    =============================================================================================================================================

    Created with:     Windows PowerShell ISE

    Created on:       10, 2017 10:02:54 PM

    Created by:       Dashrath Chate

    Organization:     Organization Name

    =============================================================================================================================================

#>

$DataOut="";

$hostnames = $env:COMPUTERNAME

foreach ($hostname in $hostnames)

{

try

{

$SystemInfodetail=Get-WmiObject -Class Win32_OperatingSystem -ComputerName $hostname

$CheckInfo=Get-WMIObject –class Win32_ComputerSystem -ComputerName $hostname

$PatchesInfo=Get-HotFix -ComputerName $hostname

$AppsInfo=Get-WmiObject -Class Win32_Product -ComputerName $hostname

$SRouts=Get-Service -ComputerName $hostname

$DriversInfo=Get-WmiObject Win32_PnPSignedDriver -ComputerName $hostname | select devicename, driverversion

$DataOut=$DataOut+"`nMachine Name: "+$hostname+"`n"

$DataOut=$DataOut+"Name,Status,DisplayName,StartType `n"

foreach ($SRout in $SRouts)

{$DataOut=$DataOut+""+$SRout.Name+","+$SRout.Status+","+$SRout.DisplayName+","+$SRout.StartType+ "`n"

}

$DataOut=$DataOut+"`nPatchesInformation `n"

$DataOut=$DataOut+"HotFixID,Description,InstalledBy,InstalledOn `n"

foreach ($Patches in $PatchesInfo)

{$DataOut=$DataOut+""+$Patches.HotFixID+","+$Patches.Description+","+$Patches.InstalledBy+","+$Patches.InstalledOn+"`n"

}

$DataOut=$DataOut+"`nApplicationInformation `n"

$DataOut=$DataOut+"IdentifyingNumber,Name,vendor,Version,Caption `n"

foreach ($Apps in $AppsInfo)

{$DataOut=$DataOut+""+$Apps.IdentifyingNumber+","+$Apps.Name+","+$Apps.vendor+","+$Apps.Version+","+$Apps.Caption+"`n"

}

$DataOut=$DataOut+"`nDriversInformation `n"

$DataOut=$DataOut+"Devicename,driverversion `n"

foreach ($Drivers in $DriversInfo)

{$DataOut=$DataOut+""+$Drivers.Devicename+","+$Drivers.driverversion+"`n"

}

$DataOut=$DataOut+"`nSystemInformation `n"

$DataOut=$DataOut+"SystemDirectory,Organization,BuildNumber,RegisteredUser,SerialNumber,Version `n"

foreach ($SystemInfo in $SystemInfodetail)

{  $DataOut=$DataOut+""+$SystemInfo.SystemDirectory+","+$SystemInfo.Organization+","+$SystemInfo.BuildNumber+","+$SystemInfo.RegisteredUser+","+$SystemInfo.SerialNumber+","+$SystemInfo.Version+"`n"

}

$DataOut=$DataOut+"Domain,Model,Manufacturer `n"

foreach ($CheckName in $CheckInfo)

{$DataOut=$DataOut+""+$CheckName.Domain+","+$CheckName.Model+","+$CheckName.Manufacturer+"`n"}

}

catch

{

$failureMsg=$_.Exception.Message

$DataOut=$DataOut+"`nHostName: "+$hostname+”,”+"$failureMsg"+"`n"

}

Set-Content -Path C:\Windows\CCM\Logs\$hostnames.csv -Value $DataOut

}

Write-Host "Data is available at C:\Windows\CCM\Logs\$hostnames.csv"

No comments:

Post a Comment

Leave your valuable words here for improve better.