Set-ADUser -Identity <name> -PasswordNeverExpires $true
Set-ADUser:术语“Set-ADUser”不能识别为cmdlet、函数、脚本文件或可操作程序的名称。请检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。行:2字符:1+Set-ADUser-identity$name-passwordneverexpires$true+~~~~~~~~~+CategoryInfo:objectnotfound:(Set-ADUser:string)[],CommandNotFoundException+FullyQualifiedErrorId:CommandNotFoundException
您需要导入ActiveDirectory模块:
Import-Module ActiveDirectory
要检查它是否存在,请执行以下操作:
Get-Module -ListAvailable
如果您没有看到ActiveDirectory模块,那么这是因为您没有安装AD LDS用户和计算机功能。转到管理-添加角色和特性。在“添加角色和功能向导”中,在“功能”选项卡上,选择“远程服务器管理工具”,然后选择“角色管理工具”-“AD DS和DF LDS工具”。
ActiveDirectory模块默认存在于windows server 2008 R2中,请按以下方式安装它:
Import-Module ServerManager
Add-WindowsFeature RSAT-AD-PowerShell