Hello all, i really need your help with this one. I have registry settings that are being generated during SCCM OSD TS. I have been asked to add the same registry settings into custom wmi class. So i need to create class in root\cimv2 and call it OSDBuild and add entries into it. My entire powershell looks like this.
$RegKeyName = "OSDBuild"
# Set values
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$FullRegKeyName = "HKLM:\SOFTWARE\" + $regkeyname
# Create Registry key
New-Item -Path $FullRegKeyName -type Directory -Force -ErrorAction SilentlyContinue
# Get values
$InstallTime = Get-Date -Format G
$OSDStartTime = $tsenv.value("OSDStartTSTime")
$AdvertisementID = $tsenv.value("_SMSTSAdvertID")
$Organisation = $tsenv.value("_SMSTSOrgName")
$TaskSequenceID = $tsenv.value("_SMSTSPackageID")
$Packagename = $tsenv.value("_SMSTSPackageName")
$MachineName = $env:computername
$Installationmode = $tsenv.value("_SMSTSLaunchMode")
$BuildRevision = $tsenv.value("BuildRevision")
$OSName = $tsenv.vlaue("OSName")
$OSDDateUTC = (Get-Date).ToUniversalTime()
#Calculate time elapsed
$OSDTImeSpan = New-TimeSpan -start $OSDStartTime -end $InstallTime
$OSDDuration = "{0:hh}:{0:mm}:{0:ss}" -f $OSDTimeSpan
# Write values
new-itemProperty $FullRegKeyName -Name "InstalledDate" -value $InstallTime -Type STRING -Force -ErrorAction SilentlyContinue | Out-Null
new-itemProperty $FullRegKeyName -Name "OSDStartTime" -value $OSDStartTime -Type STRING -Force -ErrorAction SilentlyContinue | Out-Null
New-ItemProperty $FullRegKeyName -Name "OSDDuration" -value $OSDDuration -Type STRING -Force -ErrorAction SilentlyContinue | Out-Null
new-itemProperty $FullRegKeyName -Name "OrganisationName" -value $Organisation -Type STRING -Force -ErrorAction SilentlyContinue | Out-Null
new-itemProperty $FullRegKeyName -Name "AdvertisementID" -value $AdvertisementID -Type STRING -Force -ErrorAction SilentlyContinue | Out-Null
new-itemProperty $FullRegKeyName -Name "TaskSequenceID" -value $TaskSequenceID -Type STRING -Force -ErrorAction SilentlyContinue | Out-Null
new-itemProperty $FullRegKeyName -Name "Task Sequence Name" -value $Packagename -Type STRING -Force -ErrorAction SilentlyContinue | Out-Null
new-itemProperty $FullRegKeyName -Name "Installation Type" -value $Installationmode -Type STRING -Force -ErrorAction SilentlyContinue | Out-Null
new-itemProperty $FullRegKeyName -Name "Computername" -value $MachineName -Type STRING -Force -ErrorAction SilentlyContinue | Out-Null
new-itemProperty $FullRegKeyName -Name "OSVersion" -value (Get-CimInstance Win32_Operatingsystem).version -PropertyType String -Force | Out-Null
new-itemProperty $FullRegKeyName -Name "BuildRevision" -value $BuildRevision -Type STRING -Force -ErroAction SilentlyContinue | Out-Null
new-itemProperty $FullRegKeyName -Name "OSVersionName" -value $OSversionName -Type STRING -Force -ErrorAction SilentlyContinue | Out-Null
new-itemProperty $FullRegKeyName -Name "OSDDateUTC" -value $OSDDateUTC -Type STRING -Force -ErrorAction SilentlyContinue | Out-Null