我有以下代码行,它应该获得以@符号开头的所有Active Directory组,然后从这些组中删除用户;PowerShell - 删除ADGroup不允许从Get-ADGroup-pipeil输入
Get-ADGroup -Filter 'name -like "@*"' | Remove-ADGroup -identity [USERID]
获取,广告组的伟大工程,成功地抓住所有以@开头的群体,但是通过管道时删除,广告组,我得到以下每个错误和每@组;
Remove-ADGroup : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At line:1 char:41
+ Get-ADGroup -Filter 'name -like "@*"' | Remove-ADGroup -identity [USERID]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: [email protected],O...ife,DC=co,DC=uk:PSObject) [Remove-ADGroup], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,Microsoft.ActiveDirectory.Management.Commands.RemoveADGroup
我想不通为什么管道无法正常工作。
这就是为什么你应该总是使用'-WhatIf'用'删除,'的cmdlet,直到你100%肯定你正在做的事情是正确的工作。这可以发生了很大的错误。 :-) –
非常好的一点!感谢您指出这一点,我对PowerShell颇为陌生(正如您可能会说的那样),所以从现在开始我会记住这一点! – haze1434