【发布时间】:2020-08-28 10:40:31
【问题描述】:
希望您能提供帮助。 PS新手,请耐心等待:)
我对下面的脚本有疑问。如果我将 Out-File 命令放在第 6 行,结果会打印在 powershell 屏幕中,但 txt 文件是空白的。如果我将 Out-File 命令放在第 3 行的末尾,则会填充文本文件,但它不会在 powershell 窗口中输出结果。 我希望两者都做。 郁闷:(
import-module activedirectory
$username = Read-Host 'Please enter Username!'
Get-ADPrincipalGroupMembership $username | Get-ADGroup -Properties * | select name, description | Format-Table -Wrap -AutoSize
$wsh = New-Object -ComObject Wscript.Shell
$wsh.Popup("List has been saved to C:\Group_List.txt")
Out-File C:\Group_List.txt
Read-Host -Prompt "Press Enter to exit"
【问题讨论】:
-
您希望它显示在弹出窗口中吗?也许为您的查询分配一个变量,然后以这种方式使用它?或者,如果您希望它显示在终端中,您可以执行 write-host
标签: powershell