gpt4 book ai didi

powershell - 单行 PowerShell 脚本

转载 作者:行者123 更新时间:2023-12-04 00:57:49 24 4
gpt4 key购买 nike

我已经创建了这个基本的单行 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com