小编Aur*_*ock的帖子

从Powershell调用WinRT Async方法在win8中设置帐户图片

我正在尝试将一些东西放在一起,以使用 AD 缩略图照片在 Windows 8 上设置用户的帐户图片。看来我应该能够使用 WinRT 的 API 来执行此操作。我从各种来源拼凑了一些有关从 powershell 调用 API 的信息,但我无法让它工作。这是我尝试做的一个例子:

\n
$photo = ([ADSISEARCHER]\xe2\x80\x9csamaccountname=$($username)\xe2\x80\x9d).findone().properties.thumbnailphoto\n$path = "C:\\temp\\Photo.jpg"\n$photo | set-content $path -encoding byte\n\n\n[Windows.System.UserProfile.UserInformation,Windows.System.UserProfile,ContentType=WindowsRuntime] > $null\n[Windows.System.UserProfile.UserInformation]::SetAccountPictureAsync($photo)\n
Run Code Online (Sandbox Code Playgroud)\n

我尝试了其他一些变体,但无论我做什么,我最终都会遇到这样的错误:

\n
Cannot convert argument "image", with value: "System.Object[]", for "setAccountPictureAsync" to type "Windows.Storage.IStorageFile" . . . \n
Run Code Online (Sandbox Code Playgroud)\n

我是否缺少一些简单的东西来完成这项工作?

\n

我发现Keith Hill 的这篇博文似乎可能有帮助,但我不确定它是否直接转化为我遇到的问题。

\n

谢谢!

\n

奥罗克

\n

c# powershell windows-8 windows-runtime

2
推荐指数
1
解决办法
2092
查看次数

标签 统计

c# ×1

powershell ×1

windows-8 ×1

windows-runtime ×1