Handy powershell script for IT Pros to assist in bulk validating assemblies across multiple wsps for spdispose issues.
#########################################################################################################
$deploymentfolder = "C:\SharePoint Dispose Check\ToCheck\"
$workingfolder = "C:\SharePoint Dispose Check\working\"
$spdfolder = "C:\SharePoint Dispose Check\"
$cabfoldername = "cab"
$dllfoldername = "dll"
$wspfoldername = "wsp"
$logfilename = "log_"
#########################################################################################################
$dte = get-date -format MM_dd_yyyy_HH_mm_ss
$logfilename = $logfilename+$dte+".log"
function Pause()
{
Write-Host "Press any key to continue ...";
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown");
}
Write-Host "...Change working folder" -foregroundcolor yellow
pushd $workingfolder
Write-Host "...Cleaning working folder" -foregroundcolor yellow
Remove-Item $workingfolder"*" -recurse
#Pause
Write-Host "...Create new wsp folder" -foregroundcolor yellow
New-Item $workingfolder$wspfoldername -type directory
#Pause
Write-Host "...Copy all wsps to local from deployment folder" -foregroundcolor yellow
Get-ChildItem $deploymentfolder -filter "*.wsp" -recurse | Copy-Item -destination $workingfolder$wspfoldername
#Pause
Write-Host "...Create new cab folder" -foregroundcolor yellow
New-Item $workingfolder$cabfoldername -type directory
Get-ChildItem $workingfolder$wspfoldername | Copy-Item -destination $workingfolder$cabfoldername
Get-ChildItem $workingfolder$cabfoldername | Rename-Item -NewName { $_.Name -replace "wsp","cab" }
#Pause
Write-Host "...Create new dll folder" -foregroundcolor yellow
New-Item $workingfolder$dllfoldername -type directory
#Pause
Write-Host "...Expanding dlls from cab folder" -foregroundcolor yellow
Get-ChildItem $workingfolder$cabfoldername | foreach-object{expand $workingfolder$cabfoldername"\$_" -f:*.dll $workingfolder$dllfoldername}
#Pause
get-childitem $workingfolder$dllfoldername -recurse | ForEach {$_.Set_IsReadOnly($False)}
Write-Host "...Performing SPDispose check" -foregroundcolor yellow
pushd $spdfolder
Get-ChildItem $workingfolder$dllfoldername | foreach-object{.\SPDisposeCheck.exe $workingfolder$dllfoldername"\$_" | out-file -filepath $workingfolder$logfilename -append }
notepad.exe $workingfolder$logfilename
#Pause
#########################################################################################################
$deploymentfolder = "C:\SharePoint Dispose Check\ToCheck\"
$workingfolder = "C:\SharePoint Dispose Check\working\"
$spdfolder = "C:\SharePoint Dispose Check\"
$cabfoldername = "cab"
$dllfoldername = "dll"
$wspfoldername = "wsp"
$logfilename = "log_"
#########################################################################################################
$dte = get-date -format MM_dd_yyyy_HH_mm_ss
$logfilename = $logfilename+$dte+".log"
function Pause()
{
Write-Host "Press any key to continue ...";
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown");
}
Write-Host "...Change working folder" -foregroundcolor yellow
pushd $workingfolder
Write-Host "...Cleaning working folder" -foregroundcolor yellow
Remove-Item $workingfolder"*" -recurse
#Pause
Write-Host "...Create new wsp folder" -foregroundcolor yellow
New-Item $workingfolder$wspfoldername -type directory
#Pause
Write-Host "...Copy all wsps to local from deployment folder" -foregroundcolor yellow
Get-ChildItem $deploymentfolder -filter "*.wsp" -recurse | Copy-Item -destination $workingfolder$wspfoldername
#Pause
Write-Host "...Create new cab folder" -foregroundcolor yellow
New-Item $workingfolder$cabfoldername -type directory
Get-ChildItem $workingfolder$wspfoldername | Copy-Item -destination $workingfolder$cabfoldername
Get-ChildItem $workingfolder$cabfoldername | Rename-Item -NewName { $_.Name -replace "wsp","cab" }
#Pause
Write-Host "...Create new dll folder" -foregroundcolor yellow
New-Item $workingfolder$dllfoldername -type directory
#Pause
Write-Host "...Expanding dlls from cab folder" -foregroundcolor yellow
Get-ChildItem $workingfolder$cabfoldername | foreach-object{expand $workingfolder$cabfoldername"\$_" -f:*.dll $workingfolder$dllfoldername}
#Pause
get-childitem $workingfolder$dllfoldername -recurse | ForEach {$_.Set_IsReadOnly($False)}
Write-Host "...Performing SPDispose check" -foregroundcolor yellow
pushd $spdfolder
Get-ChildItem $workingfolder$dllfoldername | foreach-object{.\SPDisposeCheck.exe $workingfolder$dllfoldername"\$_" | out-file -filepath $workingfolder$logfilename -append }
notepad.exe $workingfolder$logfilename
#Pause
No comments:
Post a Comment