hello, I am trying to understand this code and I’ve tried to put comments line by line, not sure if correct and not sure what the other lines do… hope someone can help explain? Thanks
$end = get-date // get-date result assign to end variable
$alldesks = get-content nsw.txt //get txt inside nsw.txt and assign to alldesks variable
foreach ($desk in $allDesks) { //loop, search for “desk” text in variable alldesks)
$object = Get-CalendarDiagnosticObjects -Identity $desk -StartDate “1/07/2020” -EndDate $end -ResultSize unlimited | where-object {$.ResponseType -eq 3 -and $.itemversion -eq 2 }| select EndTime,Location,SentRepresentingEmailAddress
// not sure what this does,
$date = Get-Date -Format yyyyMMdd //get-date and put in variable date using format yyyymmdd
$file = $date+“-NSW.csv” //concatenate date to NSW.CSV
foreach ($obj in $object) { //loop not sure where obj came from?
$users = Get-User $obj.SentRepresentingEmailAddress | select name //get-user obj.property assign to users variable?
$split = ($obj.Location).split(“-”).trim() //not sure what this does
$output = New-Object psobject //assign value to output variable
$output | Add-Member noteproperty “Endtime” $obj.endtime //not sure what this does
$output | Add-Member noteproperty “Building” $split[0] //not sure what this does
$output | Add-Member noteproperty “Floor” $split[1] //not sure what this does
$output | Add-Member noteproperty “Desk” $split[2] //not sure what this does
$output | Add-Member noteproperty “User” $users.name //not sure what this does
$output | export-csv -notypeinformation $file -append
}
}
$end