輸出為 .csv 的 PS Alias 指令

輸出為 .csv 的 PS Alias 指令

我嘗試運行別名命令並將結果吐出到 .csv 中。我已經運行了命令,但不確定要添加導出命令的語法。有人可以幫忙嗎?

我使用的命令為:

get-mailbox | foreach{ 

 $host.UI.Write("Blue", $host.UI.RawUI.BackGroundColor, "`nUser Name: " + $_.DisplayName+"`n")

 for ($i=0;$i -lt $_.EmailAddresses.Count; $i++)
 {
    $address = $_.EmailAddresses[$i]

    $host.UI.Write("Blue", $host.UI.RawUI.BackGroundColor, $address.AddressString.ToString()+"`t")

    if ($address.IsPrimaryAddress)
    { 
        $host.UI.Write("Green", $host.UI.RawUI.BackGroundColor, "Primary Email Address`n")
    }
   else
   {
        $host.UI.Write("Green", $host.UI.RawUI.BackGroundColor, "Alias`n")
    }
 }
}

相關內容