我使用一个名为 TALEND CSP(微软合作伙伴中心)的工具。
我编写了一个代码片段,通过它我通过 PowerShell 连接到 CSP,但搜索是由用户和密码完成的,并且需要 MFA。在需要 MFA 连接的情况下,我无法在 CSP 上设置自动化。
我希望得到建立这种联系的人的帮助。我添加上一个
这是我的代码:
#Connecting to the partner center
Connect-PartnerCenter
##Getting Customers Data
$PartnerCustomers = Get-PartnerCustomer
#Create the object we'll add values to
$CustomUserInfo = New-Object -TypeName psobject
#Create the array we'll add the objects to
[System.Collections.ArrayList]$LicenseReport = @()
foreach ($Customer in $PartnerCustomers) {
$CustomerUsers = Get-PartnerCustomerUser -CustomerId $Customer.CustomerId | select DisplayName,UserPrincipalName,State,UserId
foreach ($CustomerUser in $CustomerUsers) {
$CurrentUserLicense = Get-PartnerCustomerUserLicense -CustomerId $Customer.CustomerId -UserID $CustomerUser.UserId | select Name
$CustomUserInfo | Add-Member -MemberType NoteProperty -Name DisplayName -Value $CustomerUser.DisplayName
$CustomUserInfo | Add-Member -MemberType NoteProperty -Name Email -Value $CustomerUser.UserPrincipalName
$CustomUserInfo | Add-Member -MemberType NoteProperty -Name License -Value $CurrentUserLicense.Name
$CustomUserInfo | Add-Member -MemberType NoteProperty -Name State -Value $CustomerUser.State
$CustomUserInfo | Add-Member -MemberType NoteProperty -Name Organization -Value $Customer.Name
$CustomUserInfo.License = [string]$CustomUserInfo.License
$CustomUserInfo
$LicenseReport.Add(($CustomUserInfo))
$CustomUserInfo = New-Object -TypeName psobject
}
}
$LicenseReport | Export-Csv -Path C:\CSP\PartnerCenter_Users_License_Report.csv -Encoding UTF8