$svcAccountName = "TheAccountName"
$svcAccount = Get-LocalUser -Name $svcAccountName
服务器(Windows Server 2008 R2)拒绝使用
Get-LocalUser
命令,显示以下信息:
Get-LocalUser : The term 'Get-LocalUser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Get-LocalUser + ~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-LocalUser:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException因此,我尝试导入
LocalAccounts
模块:Import-Module Microsoft.Powershell.LocalAccounts
我得到了以下信息:
Import-Module:指定的模块“LocalAccounts”未加载,因为在任何模块目录中都找不到有效的模块文件。 在第1行第1个字符处: + Import-Module + ~~~~~~~~~~~~~ + CategoryInfo : ResourceUnavailable: (LocalAccounts:String)[Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
根据变量$PSVersionTable
,服务器正在运行PSVersion 4.0。
为什么没有加载LocalAccounts
模块和Get-LocalUser
命令?
如何解决这个问题?