Below Powershell script will report all FSLogix profiles configured in environment. Just copy paste below script and edit yellow highlighted text as per your environment and get it working.
$Date=(Get-Date).AddDays(-30)
$FormatDate = Get-Date -Format dd-MM-yyyy
$vhds=Get-ChildItem –Path “mention_profile_location” -Recurse | Where-Object {$_.Name -like “*.vhd”} | where-object {($_.LastWriteTime -lt $Date)}
ForEach($VHD in $VHDs){
If($VHD.LastWriteTime -lt $Date)
{
$VHDLWT = Get-Date $VHD.LastWriteTime -Format “dd-MM-yyyy”
$VHDCT = Get-Date $VHD.CreationTime -Format “dd-MM-yyyy”
$Profile = ($VHD.Length | Measure-Object -Sum).Sum /1GB | Out-String
$ProfileSize = $Profile | ForEach{$_.SubString(0,$_.Length-10)<#+”GB”#>}
$Report = New-Object PSObject # Creates a Custom Report #
$Report | Add-Member -MemberType NoteProperty -Name “ProfileName” -Value $VHD.Name
$Report | Add-Member -MemberType NoteProperty -Name “ProfileSize(GB)” -Value $ProfileSize
$Report | Add-Member -MemberType NoteProperty -Name “CreationTime” -Value $VHDCT
$Report | Add-Member -MemberType NoteProperty -Name “LastWriteTime” -Value $VHDLWT
$Report | Add-Member -MemberType NoteProperty -Name “ProfilePath” -Value $VHD.FullName
$Report | Export-Csv -Append -NoTypeInformation (‘C:\FSLogix_Profiles_Report_’+$FormatDate+’.csv’)
}}
$To = “To_address“
$From = “From_address“
$SMTP = “smtp_server“
$Sub = (‘FSLogix Profile Report for ‘+$FormatDate)
$Attachment = (‘C:\FSLogix_Profiles_Report_’+$FormatDate+’.csv’)
$Body =
(‘Please find Attached the FSLogix Profiles Report for ‘+$FormatDate+’.
This report contains a list of FSLogix Profiles that have not been accessed for 30 days.
Regards’)
Send-MailMessage -To $To -From $From -Subject $Sub -Body $Body -Attachments $Attachment -SmtpServer $SMTP
Edit Yellow Highlighted as per your needs.
“Imagination is more important than knowledge.” – Albert Einstein
Comment or like if this helped you in any way.
