特定のライセンスタイプが割り当てられているすべてのユーザーを検索しようとしています。 私は基本的に私のAzureモジュールv1コマンドをAzureモジュールv2コマンドに変換しようとしています。 Azure module v1コマンドと同じ結果を得る方法は?Azure Active Directory V2 PowerShell - ライセンスを取得したすべてのOffice 365ユーザーの検索
アズールV1:
$OutputFile = "C:\Export\O365LicensedADEnabledUsers.csv"
$T1 = @()
$O365Users = Get-MsolUser -All
ForEach ($O365User in $O365Users)
{
$ADuser = Get-ADUser -Filter { UserPrincipalName -eq $O365User.UserPrincipalName } -Properties whenCreated, Department, Company, Enabled
If (($ADUser.Enabled -eq $true) -and ($O365User.isLicensed -eq $true))
{
$T1 += New-Object psobject -Property @{
CollectDate = $(Get-Date);
ADUserUPN = $($ADUser.UserPrincipalName);
O365UserUPN = $($O365User.UserPrincipalName);
ADUserCreated = $($ADUser.whenCreated);
ADUserDepartment = $($ADUser.Department);
ADUserCompany = $($ADUser.Company);
ADUserEnabled = $($ADUser.Enabled);
O365Licensed = $($O365User.isLicensed)
}
}
}
$T1 = $T1 | Sort-Object -Property ADUserCreated
$T1 | Format-Table
$T1 | Export-Csv -Path $OutputFile -NoTypeInformation
Write-Host "Output to $OutputFile"
アズールV2:
私の知る限り、アズールAD V2のPowerShellでないisLicensedプロパティが存在しません。私はこれの代わりにAssignedLicensesプロパティを見つける。しかし私は確信していません。
$OutputFile = "C:\Export\O365LicensedADEnabledUsers.csv"
$T1 = @()
$O365Users = Get-AzureADUser -All $true
ForEach ($O365User in $O365Users)
{
$ADuser = Get-ADUser -Filter { UserPrincipalName -eq $O365User.UserPrincipalName } -Properties whenCreated, Department, Company, Enabled
If (($ADUser.Enabled -eq $true) -and ($O365User.AssignedLicenses -ne $null))
{
$T1 += New-Object psobject -Property @{
CollectDate = $(Get-Date);
ADUserUPN = $($ADUser.UserPrincipalName);
O365UserUPN = $($O365User.UserPrincipalName);
ADUserCreated = $($ADUser.whenCreated);
ADUserDepartment = $($ADUser.Department);
ADUserCompany = $($ADUser.Company);
ADUserEnabled = $($ADUser.Enabled);
O365Licensed = $($O365User.AssignedLicenses)
}
}
}
$T1 = $T1 | Sort-Object -Property ADUserCreated
$T1 | Format-Table
$T1 | Export-Csv -Path $OutputFile -NoTypeInformation
Write-Host "Output to $OutputFile"
:あなたは、コードの一部を変更するには、以下のコードを参照することができます。 AssignedLicensesプロパティが決してnullにならないように見えるので、あなたのチェックは機能しません。私はあなたが有効だと思うSKUが含まれているかどうかをチェックしなければならないと思います。 [ユーザーエンティティのドキュメント](https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#user-entity)、[AssignedLicense documentation]( https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/entity-and-complex-type-reference#assignedlicense-type) – juunas
テナントのサブスクライブされたSKUを取得するには、 Get-AzureAdSubscribedSku'を入力します。次に、それらのうちどれがあなたのユースケースに対して有効であるかを何らかの形で把握し、ユーザがそれらのうちの1つを持っていることを確認します。 – juunas
あなたの答えをありがとう。サンプルスクリプトを教えていただけますか? – Arbelac