トップ回答者
Get-ADUserのFilterで複数条件を入れる方法

質問
-
ユーザー:Administrator のパスワードを無期限にする操作をpowershellで行おうとしています。
ローカルユーザーについては、以下のコマンドで成功したのですが、ADユーザーの場合失敗します。
$getuser = Get-WmiObject Win32_UserAccount -Filter 'Name = "Administrator" and LocalAccount = "TRUE"' $getuser.PasswordExpires = $false $getuser.Put()
ADユーザの設定変更はSet-ADUserコマンドで成功したのですが、コマンドから「パスワードを無期限」になっているかを確認しようとしたところGet-ADUserには該当の項目がないようでした。
Set-ADUser Administrator -PasswordNeverExpires $true
Get-ADUser Administrator | Get-Member Name MemberType Definition ---- ---------- ---------- Contains Method bool Contains(string propertyName) Equals Method bool Equals(System.Object obj) GetEnumerator Method System.Collections.IDictionaryEnumerator GetEnumerator() GetHashCode Method int GetHashCode() GetType Method type GetType() ToString Method string ToString() Item ParameterizedProperty Microsoft.ActiveDirectory.Management.ADPropertyValueCollection Item(string p... DistinguishedName Property System.String DistinguishedName {get;set;} Enabled Property System.Boolean Enabled {get;set;} GivenName Property System.String GivenName {get;set;} Name Property System.String Name {get;} ObjectClass Property System.String ObjectClass {get;set;} ObjectGUID Property System.Nullable`1[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, ... SamAccountName Property System.String SamAccountName {get;set;} SID Property System.Security.Principal.SecurityIdentifier SID {get;set;} Surname Property System.String Surname {get;set;} UserPrincipalName Property System.String UserPrincipalName {get;set;}
パスワードを無期限にしているユーザ一覧は以下で取れるのですが、
Get-ADUser -Filter 'PasswordNeverExpires -eq $true'
ユーザー名がAdministratorかつパスワードが無期限といった条件でFilterを掛けるにはどうしたらよいのでしょうか。
Get-ADUser -Filter 'PasswordNeverExpires -eq $true;Name -eq Administrator' Get-ADUser : クエリ解析エラー: 'PasswordNeverExpires -eq $true ; Name -eq Administrator' エラー メッセージ: 'Operator N ot supported: ' 場所: '32'。 発生場所 行:1 文字:1 + Get-ADUser -Filter {PasswordNeverExpires -eq $true ; Name -eq Administrator} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ParserError: (:) [Get-ADUser], ADFilterParsingException + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADFilterParsingException,Micr osoft.ActiveDirectory.Management.Commands.GetADUser