MUSINGS

Powershell script to find files recursively and export to CSV

Powershell script to find files recursively and export to CSV

The following script takes 3 input’s the directory to start searching from, the file extesion we are searching for (eg. .xml) and the file name to output the results as CSV to. If a result file isn’t supplied then the results are dumped to the screen. The most interesting part of this script is this @{Name=”MB”;expression={“{0:N2}” -f ($_.LengthRead more about Powershell script to find files recursively and export to CSV[…]

Powershell script to export Exchange mailbox sizes as a CSV

Powershell script to export Exchange mailbox sizes as a CSV

The following one liner will export all mailboxes with size details to a csv file. Save it at as a .ps1 script for ease of use. Get-MailboxStatistics | where {$_.ObjectClass -eq “Mailbox”} | Sort-Object TotalItemSize -Descending | select-object @{expression={$_.DisplayName}},@{expression={$_.TotalItemSize.Value.ToMB()}},@{expression={$_.ItemCount}},@{expression={$_.StorageLimitStatus}} | Export-Csv mailboxes.csv

How to search all Stored Procedures for a reference

How to search all Stored Procedures for a reference

Viewing table dependencies will show you what SP’s depend on the table, but what if you need to find those SP’s which only reference a single field. The following queries will provide you with a list of SP’s which contain the reference you are searching for. SELECT OBJECT_NAME(id) FROM syscomments WHERE [text] LIKE ‘%look for me%’Read more about How to search all Stored Procedures for a reference[…]