#Copying report to reports folder
cd "c:\Users\nathan.pettit\Downloads\"
$report = (ls | sort "LastWriteTime" -Descending)[0]
move $report C:\Users\nathan.pettit\Documents\Reports\T1-Cases\
# Changing directory to grab the report
cd "C:\Users\nathan.pettit\Documents\Reports\T1-Cases"
# Variables
$OldCSVFile = (ls | ?{$_.CreationTime.ToShortDateString()})[0]
$NewCSVFile = (ls | ?{$_.CreationTime.ToShortDateString()})[-1]
$Engineers = @{}
$Data = Import-Csv $NewCSVFile -Delimiter "," | ?{$_."Case Owner" -notlike "Cases Taken In a Day" -and $_."Case Owner" -notlike "Copyright (c) 2000-2013 salesforce.com, inc. All rights reserved." -and $_."Case Owner" -notlike "Confidential Information - Do Not Distribute" -and $_."Case Owner" -notmatch "Generated By: Nathan Pettit " -and $_."Case Owner" -notlike "Veeam" -and $_."Case Owner" -notlike ""}
# Getting list of owners
foreach($ticket in $Data){
if(!($Engineers.ContainsKey($ticket."Case Owner"))){
$Engineers.Add($ticket."Case Owner", (New-Object System.Collections.ArrayList))
}
}
foreach($ticket in $Data)
{
if(!($Engineers.($ticket."Case Owner").Contains($ticket."Case Number")))
{
[Void]($Engineers.($ticket."Case Owner").Add($ticket."Case Number"))
}
}
$total = 0
$EngineerCallData = $Engineers.Clone()
$RawReport = @()
foreach($engineer in $Engineers.Keys)
{
$EngineerCallData.($engineer) = $Engineers.($engineer).Count
$total += $Engineers.($engineer).Count
$row = "" | Select Name, TicketCount
$row.Name += ($engineer).ToString()
$row.TicketCount += ($Engineers.($engineer).Count)
$RawReport += $row
}
$RawReport | sort "TicketCount" -Descending
good?