我在 PowerShell 中使用以下命令返回 Active Directory 中通讯组的邮件属性。
Get-ADGroup $GroupName -Properties Mail | Select-Object Mail | Format-Wide
输出看起来像(星号用于表示空白):
*
*
mygroup@mycompany.com
*
*
有什么方法可以删除在输出开头和结尾添加的空格?
最佳答案
我认为这应该有效(V2):
(Get-ADGroup $GroupName -Properties Mail | Select-Object Mail | Format-Wide | out-string).split("`n") -match '\S'
编辑:这比它需要的要复杂得多。
(Get-ADGroup $GroupName -Properties Mail | Select-Object Mail | Format-Wide | Out-String).trim()
关于powershell - 从 PowerShell 输出中删除空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19944507/