Hello again,
I reviewed the docs and I'm fairly certain I have everything OK in terms of the script but I cannot get a cmdlet to work. I'm a little unsure why I am pretty sure I installed the correct modules.
I keep getting the below error.
Get-AzureADAuditSignInLogs : The term 'Get-AzureADAuditSignInLogs' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
I tried using this to bypass the error
Install-Module AzureADPreview -AllowClobber -Force
and
Install-Module AzureADPreview
Nothing works I'm a bit lost.
This is my script, my column A has the header UserPrincipalName
$file = Import-Csv -Path "My_file_with_usernames.csv" -delimiter ","
foreach ($employee in $file) {
Get-AzureADAuditSignInLogs -Filter "UserPrincipalName eq '$User'" -Top 1 | `
select CreatedDateTime, UserPrincipalName, IsInteractive, AppDisplayName, IpAddress, TokenIssuerType, @{Name = 'DeviceOS'; Expression = {$_.DeviceDetail.OperatingSystem}}
#write data to file
$userData += $OutputData;
$userData | Export-csv -path C:\Path-to-my-CSV -Append -Encoding UTF8
}
The purpose of this script is to go take everyone from Column A in my CSV (UserPrincipalName) and get the following info
Lastlogindate
Interactive login or not
What IP they are logging in from
What application they logged in from
OS
Does this look correct? Thank you VERY much again!