Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2314

Encoding Problem Export-Csv

$
0
0

Hallo Zusammen

Ich habe in der Firma ein Powershellscript geschrieben, das die Mitglieder einer Mailboxgruppe auslesen und in eine CSV-Datei schreiben soll. Beim Öffnen der CSV-Datei steht dann nur folgendes drin: ÿþ

Ich vermute das Problem liegt bei der Encodierung. Ich habe schon alles versucht und komme nicht weiter

Script sieht so aus:

#Enable Exchange cmdlets
add-pssnapin *exchange* -erroraction SilentlyContinue
$mbcombCollection = @()
[Int] $intSucceeded = 0
[Int] $intTotalRules = 0
ForEach ($i in $args)
{
    [string]$CurrGroup = $i
    $GroupMembers = Get-DistributionGroupMember -Identity $CurrGroup -ResultSize unlimited
    ForEach ($mbx in $GroupMembers)
    {
    	Write-Progress -Activity "Checking Mailbox Rules" -Status "Mailboxes Successfully Processed: $intSucceeded"
        $user = ""

        $mbcomb = "" | Select "Anrede", "Vorname", "Nachname", "Mail" ,"Gruppe"

        if ($mbx.RecipientType -eq "UserMailbox"){
        $mbxstr = Get-Mailbox -Identity $mbx.SamAccountName
        $mbxstr = $mbxstr.SamAccountName
        $user = Get-User -Identity $mbxstr
        }

        $mbcomb."Anrede" = $user.title
        $mbcomb."Vorname" = $mbx.FirstName
        $mbcomb."Nachname" = $mbx.LastName
        $mbcomb."Mail" = $mbx.PrimarySmtpAddress
        $mbcomb."Gruppe" = $CurrGroup
        $mbcombCollection += $mbcomb

    	$intSucceeded++
    }
}

#$mbcombCollection
$mbcombCollection | Export-Csv C:\_Support\Mail-Adressen\export\MailAddresses.csv


#Pause: beide Befehle einkommentieren
#Write-Host "Press any key to continue ..."
#$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Ich wäre sehr froh, wenn mir jemand weiterhelfen könnte.

Gruss
codesofa


Viewing all articles
Browse latest Browse all 2314