Martin Bodocky

No less, no more. Just live between code.

Run the SPDisposeCheck in the PowerShell


Hi All,

I have made these days some deployments and I wanted test all my source code in one way.  Making script in PowerShell is my outcome.  Script contains recursive getting files with “.dll” extension, yes I can do the same with extension “.wsp” and unzip package and I decided it might be as simple as possible. Later on, it creates folder in your current location and all output are written there.

Have a look :)

function global:Get-SPDisposeCheck

 {

Write-Host “Recursive check current location …”

$path = $PWD.Path 

#checking actual location recursively 

$Dir = get-childitem $path -recurse 

#all files with dll extension 

$List = $Dir | where {$_.extension -eq“.dll”

#made new folder for results 

$export = $path+ “\” “SPCheck_$((get-date).toString(‘yyyyMMdd-hhmmss’))”

$dir = md $export 

#on every file execute SPDisposeCheck 

$List | ForEach-Object

Write-Host$_.Name “is beeing checked…” 

$report = $export + “\” + $_.Name + “.spdisposecheck.txt” 

#in some point, you can use the same dll files, it will be overridden 

& “C:\Program Files (x86)\Microsoft\SharePoint Dispose Check\SPDisposeCheck.exe”$_.fullname | Out-File $report -Force }

#open result folder to review 

explorer $export 

}

Execute in PowerShell and see output:

Happy SharePointing guys :)

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: