You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First thanks for time and effort spent for providing these scripts.
I am to time constraint to do a PR for this so I hope it is ok, to share it via this post.
I am not able to share my script as I use DevOPS so removed 85% of the code for the [Windows 365 Cloud PC Usage Report] script.
Some things that I encountered or changed.
The current version check for the mggraph version does not work, as it does a compare on a string value for version(not on a integer), so this has no added benefit.
I would suggest to remove this or rewrite it so it does upgrade or ask for a upgrade, no added benefit with the current check as the scripts continues to work.
The second is I do not like to be using the AzureADpreview module, so I replaced the line: $Logons = Get-AzureADAuditSignInLogs -Filter "startswith(userPrincipalName,'$($CloudPCUser.UserPrincipalName)') and appdisplayname eq 'Windows Sign In' and createdDateTime gt $string"
With: $Logons = Get-MgAuditLogSignIn -Filter "startsWith(userPrincipalName,'$($CloudPCUser.UserPrincipalName)') and appdisplayname eq 'Windows Sign In' and createdDateTime gt $string"
And removed all lines of code that were needed for the AzureADpreview connection.
This way it 100% uses the mggraph modules.
The code below does not work as the variable $total is never set $count should be used.
Line 255
if ($total -eq 0) { write-host "User has not logged in." -ForegroundColor Red }
I rewrote that to this so it also writes an entry that no logons were found in the past $offset days.
#Counts each web logon
foreach ($Logon in $Logons) {
if (($Logon.UserPrincipalName -eq $CloudPCUser.UserPrincipalName) -and ($Logon.DeviceDetail.Displayname -like "CPC-*") -and ($Logon.DeviceDetail.DeviceID -eq $CloudPCUser.AadDeviceId)) {
$count = $count + 1
if ($logon.CreatedDateTime -gt $LastLogon) { $LastLogon = $Logon.CreatedDateTime }
#outputs local client logon count
write-host "Logon count is $count"
$output.Logons = $count
#outputs the last logon time
write-host "User's last logon time is(UTC)"$LastLogon
$output.LastLogon = $LastLogon
}
}
#outputs notification if no logon activity has been recorded
if ($count -eq $null) {
$count = 0
write-host "No logons found in past $offset days."
$output.Logons = $count
$output.LastLogon = "No logons found in past $offset days."
}
The text was updated successfully, but these errors were encountered:
First thanks for time and effort spent for providing these scripts.
I am to time constraint to do a PR for this so I hope it is ok, to share it via this post.
I am not able to share my script as I use DevOPS so removed 85% of the code for the [Windows 365 Cloud PC Usage Report] script.
Some things that I encountered or changed.
The current version check for the mggraph version does not work, as it does a compare on a string value for version(not on a integer), so this has no added benefit.
I would suggest to remove this or rewrite it so it does upgrade or ask for a upgrade, no added benefit with the current check as the scripts continues to work.
The second is I do not like to be using the AzureADpreview module, so I replaced the line:
$Logons = Get-AzureADAuditSignInLogs -Filter "startswith(userPrincipalName,'$($CloudPCUser.UserPrincipalName)') and appdisplayname eq 'Windows Sign In' and createdDateTime gt $string"
With:
$Logons = Get-MgAuditLogSignIn -Filter "startsWith(userPrincipalName,'$($CloudPCUser.UserPrincipalName)') and appdisplayname eq 'Windows Sign In' and createdDateTime gt $string"
And removed all lines of code that were needed for the AzureADpreview connection.
This way it 100% uses the mggraph modules.
The code below does not work as the variable $total is never set $count should be used.
I rewrote that to this so it also writes an entry that no logons were found in the past $offset days.
The text was updated successfully, but these errors were encountered: