95 lines
3.9 KiB
PowerShell
95 lines
3.9 KiB
PowerShell
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
|
|
|
|
$ts = new-object -comobject microsoft.sms.tsenvironment
|
|
$ErrorReturnCode = $ts.value("_SMSTSLastActionSucceeded")
|
|
$UpgradeErrorReturnCode = $ts.value("_SMSTSLastActionRetCode")
|
|
$My_DeployRoot = $ts.value("DeployRoot")
|
|
$Step_Lang = $ts.value("Item_Name")
|
|
$Step_Version = $ts.value("Item_Version")
|
|
$Computer_Name = $ts.value("MyComputer")
|
|
$XML_Status_Folder = $ts.value("XML_Status")
|
|
|
|
$Item_Catalog = $ts.value("Catalog_Value")
|
|
$Appli_Name = $Step_Lang.Replace("__"," ")
|
|
$Step_Name = "$Item_Catalog - $Step_Lang"
|
|
|
|
$Date = get-date -format 'dd/MM/yy - HH:mm'
|
|
$Temp_folder = $env:TEMP
|
|
$Windir_folder = $env:windir
|
|
$Results_File = "$Temp_folder\Results.xml"
|
|
$Test_Results_File = test-path $Results_File
|
|
|
|
# Load the results from c:\windows\temp\deploymentlogs\results.xml
|
|
If ($Test_Results_File)
|
|
{
|
|
$Input_Status = [xml] (Get-Content $Results_File)
|
|
foreach ($data in $Input_Status.selectNodes("Results"))
|
|
{
|
|
$Errors_NB = $data.Errors
|
|
$Warnings_NB = $data.Warnings
|
|
$RetVal_Value = $data.RetVal
|
|
$DeploymentType_Value = $data.DeploymentType
|
|
$Messages_Value = $data.Messages.innertext
|
|
}
|
|
}
|
|
|
|
If ($Messages_Value -eq "")
|
|
{
|
|
$Messages_Value = "No message"
|
|
}
|
|
|
|
|
|
# Populate file Catalog_Error_Status.xml with values from results.xml
|
|
$Catalog_Error_XML = "$My_DeployRoot\Scripts\Catalog_Error_Status.xml"
|
|
[xml]$Error_Status_XML = (Get-Content $Catalog_Error_XML)
|
|
$new_step = $Error_Status_XML.Steps.AppendChild($Error_Status_XML.CreateElement("Step"));
|
|
|
|
$new_step_name = $new_step.AppendChild($Error_Status_XML.CreateElement("Computer"));
|
|
$newXmlLabelTextNode = $new_step_name.AppendChild($Error_Status_XML.CreateTextNode("$Computer_Name"));
|
|
|
|
$new_step_name = $new_step.AppendChild($Error_Status_XML.CreateElement("Name"));
|
|
$newXmlLabelTextNode = $new_step_name.AppendChild($Error_Status_XML.CreateTextNode("$Appli_Name"));
|
|
|
|
$new_step_version = $new_step.AppendChild($Error_Status_XML.CreateElement("Version"));
|
|
$newXmlFolderTextNode = $new_step_version.AppendChild($Error_Status_XML.CreateTextNode("$Step_Version"));
|
|
|
|
$new_step_Date = $new_step.AppendChild($Error_Status_XML.CreateElement("Date"));
|
|
$newXmlFolderTextNode = $new_step_Date.AppendChild($Error_Status_XML.CreateTextNode("$Date"));
|
|
|
|
$new_step_Error_Number = $new_step.AppendChild($Error_Status_XML.CreateElement("Error_Number"));
|
|
$newXmlVersionTextNode = $new_step_Error_Number.AppendChild($Error_Status_XML.CreateTextNode("$Errors_NB"));
|
|
|
|
$new_step_Warning_Number = $new_step.AppendChild($Error_Status_XML.CreateElement("Warning_Number"));
|
|
$newXmlFlagTextNode = $new_step_Warning_Number.AppendChild($Error_Status_XML.CreateTextNode("$Warnings_NB"));
|
|
|
|
$new_step_RetVal = $new_step.AppendChild($Error_Status_XML.CreateElement("RetVal"));
|
|
$newXmlFlagTextNode = $new_step_RetVal.AppendChild($Error_Status_XML.CreateTextNode("$RetVal_Value"));
|
|
|
|
$new_step_Message = $new_step.AppendChild($Error_Status_XML.CreateElement("Message"));
|
|
$newXmlFlagTextNode = $new_step_Message.AppendChild($Error_Status_XML.CreateTextNode("$Messages_Value"));
|
|
|
|
$Error_Status_XML.Save($Catalog_Error_XML);
|
|
|
|
|
|
If ($Item_Catalog -eq "Application")
|
|
{
|
|
# Create registry Key for the Application part
|
|
If (($Errors_NB -eq "0") -and ($RetVal_Value -eq "0"))
|
|
{
|
|
$Catalog_Reg_Path = "HKLM:\SOFTWARE\MDT_Catalog"
|
|
$Test_Catalog = Test-path $Catalog_Reg_Path
|
|
If ($Test_Catalog -ne $true)
|
|
{
|
|
New-Item -Path "HKLM:\SOFTWARE" -Name "MDT_Catalog"
|
|
New-Item -Path "HKLM:\SOFTWARE\MDT_Catalog" -Name "Applications"
|
|
}
|
|
|
|
$Catalog_Registry_Path = "HKLM:\SOFTWARE\MDT_Catalog\Applications"
|
|
New-Item -Path $Catalog_Registry_Path -Name $Appli_Name -Force
|
|
|
|
$Appli_Key = "$Catalog_Registry_Path\$Appli_Name"
|
|
|
|
New-ItemProperty -Path "$Appli_Key" -Name "Name" -Value $Appli_Name -PropertyType String -Force | Out-Null
|
|
New-ItemProperty -Path "$Appli_Key" -Name "Version" -Value $Step_Version -PropertyType String -Force | Out-Null
|
|
}
|
|
} |