Hi All,
Sometimes, in BizTalk server environments, we need to check the DLL based on length. Below is the sample script for that.
At the end, it will generate CSV file that contains the mismatched DLLs.
$Filepath = Split-Path -parent $MyInvocation.MyCommand.Definition
$output = $Filepath + "\output.csv"
$Sourceserver = ‘SourceServer’ # Source Server
$DestServers = "DesinationServer1","DesinationServer2","DesinationServer3" # Desination servers that needs to GAC DLL comparison
$GACFolders = "C:\Windows\Microsoft.NET\assembly\GAC_MSIL","C:\Windows\assembly\GAC_MSIL" # these are the GAC folders that needs to be used for comparison.
$AssembliesList = @()
$DiffAssemblies = @()
$ServerAssemblies = @()
foreach ($Server in $Sourceserver)
{
foreach ($gacfolder in $GACFolders)
{
$ScriptBlockContent = {
param ($Folder)
get-childitem -Path $Folder -filter ‘*.dll’ -Recurse |select name,length,fullname }
$AssembliesList += Invoke-Command -ComputerName $Server -ScriptBlock $ScriptBlockContent -ArgumentList $gacfolder
}
}
function getsizeDiff
{
foreach ($Dserver in $DestServers)
{
$ServerAssemblies = @()
foreach ($gacfolder in $GACFolders)
{
$ScriptBlockContent = {
param ($Folder)
get-childitem -Path $Folder -filter ‘*.dll’ -Recurse |select name,length,fullname }
$ServerAssemblies += Invoke-Command -ComputerName $Dserver -ScriptBlock $ScriptBlockContent -ArgumentList $gacfolder
}
foreach ($sAssebly in $ServerAssemblies)
{
$AssembliesList | Where-Object { $_.fullname -eq $sAssebly.fullname } |ForEach-Object {
if ( $_.length -ne $sAssebly.length)
{
$DiffAssemblies += [pscustomobject] @{
ServerName=$Dserver
AssemblyName=$sAssebly.name
AssemblyFullName=$sAssebly.fullname
Size=$sAssebly.length
}
$DiffAssemblies | Select-Object -Property ServerName,AssemblyName,AssemblyFullName,Size -Unique | Export-Csv -Path $output -NoTypeInformation
}
}
}
}
}
getsizeDiff
Regards,
Chaitanya