| Server IP : 123.56.80.60 / Your IP : 216.73.216.33 Web Server : Apache/2.4.54 (Win32) OpenSSL/1.1.1s PHP/7.4.33 mod_fcgid/2.3.10-dev System : Windows NT iZhx3sob14hnz7Z 10.0 build 14393 (Windows Server 2016) i586 User : SYSTEM ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Windows/diagnostics/system/WindowsUpdate/ |
Upload File : |
# Copyright © 2012, Microsoft Corporation. All rights reserved.
function Get-MATSTemp()
{
$CABDirs = get-childitem "$env:temp\mats-temp\cab*.*"
if ($CABDirs.count -gt 0)
{
$CABDirs = Sort-Object -InputObject $CABDirs -Property LastWriteTime -Descending
return $CabDirs[0]
}
else
{
return $CABDirs
}
}
# Our implementation of a .PSD1 importer
function Import-LocalizedData($FileName, $BindingVariable, $BaseDirectory, $UICulture)
{
if ($baseDirectory -eq $null)
{
$base= "$pwd"
}
else
{
$base = $basedirectory
}
$mats = Get-MATSTemp
if ($UICulture -ne $null)
{
$culture = $UICulture
}
else
{
$culture = (get-culture).name
}
$locations = "$base\$culture", "$mats\$culture", "$base", "$mats"
foreach ($location in $locations)
{
if ([System.IO.File]::Exists("$location\$filename.psd1"))
{
$fullpath = "$location\$filename.psd1"
break
}
}
if (![System.IO.File]::Exists($fullpath))
{
throw "File not Found: $fullpath" # Write to error output
}
$stringtable = "" | Select-Object StringTableFileName # Return object
$sourceStrings = [System.IO.File]::ReadAllLines($fullpath) # Array of strings in .PSD1 file
$stringtable.StringTableFileName = $filename # Place the filename in the stringtable
for ($i = 0; $i -lt $sourceStrings.count; $i++) # Loop over all strings
{
if ($sourceStrings[$i].contains("=")) # Simple check for "xx=yy" pattern
{
$stringID = $sourceStrings[$i].Substring(0, $sourceStrings[$i].IndexOf("=")) # Get String ID
$stringValue = $sourceStrings[$I].SubString($SourceStrings[$i].IndexOf("=")+1) # Get String Value
add-member -inputobject $StringTable -membertype noteproperty -name $stringID -value $stringValue # Add this StringID/Value to the return object
}
}
set-variable -Name $bindingvariable -Value $stringtable -Scope "global" # 'return' the completed string table
} # Import-LocalizedData
# Simple implementation of PowerShell 2.0 add-type cmdlet
function Add-Type
{
param([string]$TypeDefinition, [Array]$ReferencedAssemblies, [switch]$passthru)
# Create Provider
$csprovider = new-object Microsoft.CSharp.CSharpCodeProvider
# Configure the compiler
$CompilerParams = new-object System.CodeDom.Compiler.CompilerParameters
$CompilerParams.GenerateInMemory = $true
# Add some default assemblies
$CompilerParams.ReferencedAssemblies.Add("system.dll") > $null
$CompilerParams.ReferencedAssemblies.Add([PSObject].assembly.location) > $null
# add user-defined assemblies
if ($referencedassemblies.count -gt 0)
{
for ($i = 0; $i -lt $referencesassemblies.count; $i++)
{
$CompilerParams.ReferencedAssemblies.Add($ReferencedAssemblies[$i])
}
}
# compile the code
$Result = $csprovider.compileAssemblyFromSource($CompilerParams, $TypeDefinition)
# check for success
if ($Result.errors.count -gt 0)
{
write-error $Result
}
else
{
if ($passthru)
{
$Result.compiledassembly.getexportedtypes()
}
}
}
# Simple implentation of ConvertTo-XML
function ConvertTo-XML
{
Param($InputObject)
Begin
{
$xmlSource = ""
$xmlSource += "<?xml version=""1.0""?><Objects>"
}
Process
{
if ($_)
{
$InputObjectType = $_.GetType.TypeNameOfValue
$xmlsource += "<Object Type=""System.Management.Automation.PSCustomObject"">"
#$xmlSource = ""
#$xmlSource += "<?xml version=""1.0""?><Objects><Object Type=""System.Management.Automation.PSCustomObject"">"
$Properties = @()
if ((Get-Member -inputobject $_ -MemberType Property) -ne $null ){ $Properties += Get-Member -inputobject $_ -MemberType Property }
if ((Get-Member -inputobject $_ -MemberType NoteProperty) -ne $null ){ $Properties += Get-Member -inputobject $_ -MemberType NoteProperty }
$specialChars = @{"Source"="<";Dest="<"}, @{"Source"=">";Dest=">"}, @{"Source"="&";Dest="&"}
for ($PropertyCount = 0; $PropertyCount -lt $Properties.Count; $PropertyCount++)
{
[string]$PropName = $Properties[$PropertyCount].Name
[string]$PropDef = $Properties[$PropertyCount].Definition
[string]$PropType = $PropDef.Split(" ")[0]
[string]$Value = $_.$PropName
foreach ($entry in $specialChars)
{
$Value = $Value.Replace($Entry.Source, $Entry.Dest)
}
$xmlSource += "<Property Name=""$PropName"" Type=""$PropType"">$Value</Property>"
}
#$xmlSource += "</Object></Objects>"
$xmlSource += "</Object>"
#$xmlSource
}
}
End
{
if ($InputObject)
{
$InputObjectType = $InputObject.GetType.TypeNameOfValue
$xmlSource = ""
$xmlSource += "<?xml version=""1.0""?><Objects><Object Type=""System.Management.Automation.PSCustomObject"">"
if ((Get-Member -inputobject $InputObject -MemberType Property) -ne $null ){$Properties = Get-Member -inputobject $InputObject -MemberType Property }
if ((Get-Member -inputobject $InputObject -MemberType NoteProperty) -ne $null ){$Properties += Get-Member -inputobject $InputObject -MemberType NoteProperty }
$specialChars = @{"Source"="<";Dest="<"}, @{"Source"=">";Dest=">"}, @{"Source"="""";Dest="""}, @{"Source"="&";Dest="&"}
for ($PropertyCount = 0; $PropertyCount -lt $Properties.Count; $PropertyCount++)
{
[string]$PropName = $Properties[$PropertyCount].Name
[string]$PropDef = $Properties[$PropertyCount].Definition
[string]$PropType = $PropDef.Split(" ")[0]
[string]$Value = $InputObject.$PropName
foreach ($entry in $specialChars)
{
$Value = $Value.Replace($Entry.Source, $Entry.Dest)
}
$xmlSource += "<Property Name=""$PropName"" Type=""$PropType"">$Value</Property>"
}
$xmlSource += "</Object></Objects>"
$xmlSource
}
else
{
$xmlSource += "</Objects>"
$xmlSource
}
}
}
###########
# Pop up window
############
function Pop-Msg {
param([string]$msg ="message",
[string]$ttl = "Title",
[int]$type = 64)
$popwin = new-object -comobject wscript.shell
$null = $popwin.popup($msg,0,$ttl,$type)
remove-variable popwin
}