简体   繁体   English

Powershell管道变量无输出

[英]Powershell Pipeline Variable No Output

I'm trying to get all the user photos from my office365 server. 我正在尝试从Office365服务器获取所有用户照片。 I need them to show in the Alias format which is firstname.lastname 我需要它们以Alias格式显示,即firstname.lastname

get-mailbox | % {Get-UserPhoto $_.alias} | % {Set-Content -path "c:\\export\\$($_.alias).jpg" -value $_.picturedata -Encoding byte}

This works, but gives me First Name Last Name 这可行,但是给我名字姓

Someone told me I need to pass mailbox parameters through the pipeline, to do what I want to do. 有人告诉我,我需要通过管道传递邮箱参数,才能完成我想做的事情。

get-mailbox -PipelineVariable Mailbox | % {Get-UserPhoto $Mailbox.alias} | % {Set-Content -path "c:\\export\\$($Mailbox.alias).jpg" -value $_.picturedata -Encoding byte}

This is my new code, but it's not spitting out photos into directory. 这是我的新代码,但没有将照片分散到目录中。 Does anyone know why this isn't working? 有人知道为什么这行不通吗?

Cannot check this now, but I think this may work: 现在无法检查,但我认为这可能有效:

Get-Mailbox | ForEach-Object { 
    $photo = Get-UserPhoto -Identity $_.alias
    Set-Content -Path "c:\export\$($_.alias).jpg" -value $photo.picturedata -Encoding byte
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM