Изброявам всички „Свойства на потребителския профил“ в конзолата по „Показвано име, име и тип“ Има ли лесен начин за експортиране на изхода на таблицата в конзолата в csv файл?
Това вероятно е въпрос, който е задаван много пъти преди, но не мога да намеря добър начин да направя това.
Заснемане на изхода в конзолата.
Скрипт
###############################################################################
# Export user profile properties to csv
###############################################################################
. .\Environment.ps1
Write-Host "Retrieving User Profile Properties with $DomainUser at $FinalMySiteURL" -ForegroundColor Cyan
[void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server");
$site=new-object Microsoft.SharePoint.SPSite("$FinalMySiteURL");
$serviceContext = Get-SPServiceContext $site;
$site.Dispose();
Write-Host "Getting user profile manager ..." -NoNewline
Try
{
$upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);
Write-Host "Done" -ForegroundColor Green
}
Catch [system.exception]
{
Write-Host "Error loading file, add $DomainUser as admin to the user profile service (admin/privillage)" -ForegroundColor Red
Break
}
$userProfile = $upm.GetUserProfile("$DomainUser");
$userProfileProperties = $userProfile.Properties | sort DisplayName | FT DisplayName,Name,@{Label="Type";Expression={$_.CoreProperty.Type}}
$userProfileProperties
Write-Host "Export to output to csv file ..." -NoNewline
Try
{
$userProfileProperties | Export-Csv $scriptPath\UserProfileProperties.csv
Write-Host "Done" -ForegroundColor Green
}
Catch [system.exception]
{
Write-Host "Error loading file, add $DomainUser as admin to the user profile service (admin/privillage)" -ForegroundColor Red
Break
}