#http://hilite.me/ #Create folder $Path = "C:\Temp\PowerShell - Enterprise\PSTN\90 days" # Location of file to be saved $PSTNLicenseUserSource = Import-Csv -Path "$($path)\PSTNLicenseUserDomesticlCalling120.csv" # CSV file having list of user with license $30DaysTeamsLogs = Import-Csv -Path "$($path)\TeamsLogs.csv" # CSV file downloaded from Teams logs for last 30 days $Datetime= Get-Date -Format dd_MM_yyyy_HH.mm.ss $LogFileName=([string]::Concat("$($path)\Teams_Report " , $Datetime ,".csv")) New-Item $LogFileName -ItemType file Add-Content $LogFileName -Value ([string]::Concat("Email"+","+ "Total Call" +","+ "Accessed in 30 days Yes/No")) ForEach ($PSTNLicenseUser in $PSTNLicenseUserSource) { $30DaysTeamLogsSingleUserData = $30DaysTeamsLogs | where {$_.UPN -eq $PSTNLicenseUser."User principal name" } $DataMatchInTeamsLogs = $30DaysTeamLogsSingleUserData | Select-Object -first 1 If($DataMatchInTeamsLogs) # If record gets found { #Write-Host $DataMatchInTeamsLogs.UPN -ForegroundColor green #Add-Content $LogFileName -Value ([string]::Concat($($DataMatchInTeamsLogs.UPN) +","+ $($DataMatchInTeamsLogs."Duration Seconds") +","+ "Yes")) } else #Unable to find the record { Write-Host $PSTNLicenseUser."User principal name" -ForegroundColor white Add-Content $LogFileName -Value ([string]::Concat($($PSTNLicenseUser."User principal name") +","+ "0" +","+ "No")) } }
Wednesday, May 19, 2021
Finding data in CSV file from other CSV file
Subscribe to:
Posts (Atom)
HTML
Script: