我已经创建了这个基本的单行 PowerShell 脚本,如果我运行 ad
就会执行该脚本。 AD 的 cmdlet,然后是查询的其余部分。但是尝试将它们一起运行似乎只会加载 cmdlet 而不会执行 cmd 的其余部分。
powershell.exe -command "&{Import-Module ActiveDirectory; Get-AdGroup -Server DC.Mydomain.com -filter 'name -eq "xxxx"'| set-Adgroup -Replace @{wWWHomePage='10.24.218.194'}}"
为什么它不像这样一起运行?
最佳答案
答案是转义双引号:
powershell.exe -noprofile -command "&Import-Module ActiveDirectory; Get-AdGroup -Server server.mydomain.com -filter 'name -eq *\"xxxx\"*'| set-Adgroup -Replace @{wWWHomePage='10.10.10.10'}"
基本上,我从 SQL 运行它来更新一个无法通过 DSADD 访问的 ActiveDirectory 属性。
关于powershell - 单行 PowerShell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10391613/