当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] Office 365:查找用户创建日期

作者:精品下载站 日期:2024-12-14 21:31:24 浏览:13 分类:玩电脑

Office 365:查找用户创建日期


要求:查找 Office 365 中用户帐户的创建日期。

如何查找 Office 365 用户帐户的创建日期?

了解用户 Office 365 帐户的创建日期可能是非常有用的信息。它可以帮助您确定他们使用该服务进行审计的时间有多长。幸运的是,可以快速轻松地找到这些信息。让我们看一下如何检索 Office 365 用户帐户的创建日期。

从 Azure AD 管理中心获取用户创建日期

要在 Microsoft 365 中查找用户的创建日期,您可以按照以下步骤操作:

  1. 使用管理员帐户登录 Azure AD 管理中心:https://aad.portal.azure.com。
  2. 在左侧导航中,转至用户 > 搜索,然后选择要查找其创建日期的用户的名称。
  3. 在“概述”选项卡下的“基本信息”部分中,您将找到用户的“创建日期时间”。

    [玩转系统] Office 365:查找用户创建日期

或者,您可以使用 PowerShell 查找用户的创建日期。

通过 PowerShell 查找用户的创建日期

了解 Office 365 用户帐户创建时间的另一种最快方法是使用 PowerShell。为此,您需要使用 Azure AD PowerShell 模块中的 Get-AzureADUser cmdlet。此 cmdlet 从 Azure AD 检索用户对象,并包含 CreationDateTime 属性,该属性表示创建用户的日期和时间。

以下示例说明了如何使用 Get-AzureADUser cmdlet 获取用户的创建日期:


# Import the Azure AD module
Import-Module AzureAD

# Parameter
$UserID = "[email protected]"

# Connect to Azure AD
Connect-AzureAD

# Get the user object for the user with the specified email address
$User = Get-AzureADUser -Filter "mail eq '$UserID'" -ErrorAction SilentlyContinue

# Get the user's creation date
Write-host $User.ExtensionProperty.createdDateTime

这将检索电子邮件地址为“[email protected]”的用户的用户对象,并显示 CreationDateTime 属性,该属性表示用户的创建日期和时间。要获取所有用户的用户创建日期并导出到 CSV,请使用以下命令:


# Import the Azure AD module
Import-Module AzureAD

# Connect to Azure AD
Connect-AzureAD

# Get the user object for the user with the specified email address
$Users = Get-AzureADUser -All:$true 

$UserData = @()
# Iterate through each user
$Users | ForEach-Object {
    Write-Host "Getting created date for" $_.UserPrincipalName

    #Collect the user data
    $UserData += New-Object PSObject -property $([ordered]@{ 
        ObjectId  = $_.ObjectId            
        DisplayName = $_.DisplayName
        UserPrincipalName = $_.UserPrincipalName
        CreatedDateTime = $_.ExtensionProperty.createdDateTime
    })
}

#Export to CSV
$UserData
$UserData | Export-CSV "C:\Temp\UsersCreationDate.csv" -NoTypeInformation

该脚本将检索用户列表,迭代每个用户,收集用户的创建日期时间以及其他可用属性,最后将其导出到 CSV 文件。

请记住,您需要安装 Azure AD PowerShell 模块并拥有访问 Azure AD 的权限才能使用 Get-AzureADUser cmdlet。您可以通过运行以下命令来安装 Azure AD PowerShell 模块:


Install-Module AzureAD

有关使用 PowerShell 使用 Azure AD 的更多信息,可以参阅如何使用 PowerShell 连接到 Azure AD?

获取上个月创建的所有 Microsoft 365 用户

若要获取过去一个月在 Office 365 中创建的所有用户的列表,可以使用 Azure Active Directory (AAD) PowerShell 模块。这是一个示例脚本,演示了如何执行此操作。


# Import the Azure AD module
Import-Module AzureAD

# Connect to Azure AD
Connect-AzureAD

# Calculate the date and time one month ago
$OneMonthAgo = (Get-Date).AddMonths(-1)

# Get a list of all users created in the past month
$Users = Get-AzureADUser -All:$true | Where-Object {[System.DateTime]$_.ExtensionProperty.createdDateTime -gt $OneMonthAgo}

$UserData = @()
# Iterate through each user
$Users | ForEach-Object {
    Write-Host "Getting created date for" $_.UserPrincipalName

    #Collect the user data
    $UserData += New-Object PSObject -property $([ordered]@{ 
        ObjectId  = $_.ObjectId            
        DisplayName = $_.DisplayName
        UserPrincipalName = $_.UserPrincipalName
        CreatedDateTime = $_.ExtensionProperty.createdDateTime
    })
}

#Export to CSV
$UserData
$UserData | Export-CSV "C:\Temp\UsersCreationDate.csv" -NoTypeInformation

首先,此脚本使用 Connect-AzureAD cmdlet 连接到 Azure AD。然后,它使用 Get-Date cmdlet 获取当前日期和时间,并使用 AddMonths 方法计算一个月前的日期和时间。接下来,它使用 Get-AzureADUser cmdlet 获取 Azure Active Directory 中所有用户的列表,并使用 Where-Object cmdlet 筛选结果以仅包含用户谁是在一个月前的日期和时间之后创建的。

最后,它使用对象数组收集用户详细信息,选择 DisplayName ObjectIDUserPrincipalNameCreatedDateTime属性,然后将数据导出到 CSV 文件。

结论

如您所见,查找 Office 365 用户帐户的创建时间是一个相对简单的过程,不需要任何特殊技能或知识。可以使用 Azure Active Directory (AAD) 或 PowerShell 模块查找在 Office 365 中创建用户的日期。您可以检索满足特定条件的用户列表,例如在特定时间范围内创建的用户。只需几分钟即可找到有关用户帐户的重要信息。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯