使用PowerShell为用户创建主目录时出错

时间:2013-12-16 09:59:23

标签: windows powershell user-accounts

我已经看到以下建议为用户创建主目录。所以我尝试了以下脚本来创建一个主目录:

 $sec_password = ConvertTo-SecureString 'Password' -AsPlainText -Force;
$credential = New-Object System.Management.Automation.PSCredential -ArgumentList 'BLR2202710\Administrator', $sec_password;
Start-Process cmd /c -WindowStyle Hidden -Credential $credential -ErrorAction SilentlyContinue;  
$user = Get-WmiObject -Namespace root/cimv2 -Class win32_useraccount -Filter "LocalAccount=True AND Name='account17'";
$userprofile = Get-WmiObject -Namespace root/cimv2 -Class win32_userprofile -Filter "SID='$($user.sid)' ";
$userprofile.localpath;

但它失败并出现以下异常: '无法使用指定的命名参数解析参数集。     + CategoryInfo:InvalidArgument:(:) [Start-Process],ParameterBindingException     + FullyQualifiedErrorId:AmbiguousParameterSet,Microsoft.PowerShell.Commands.StartProcessCommand'

我在

中遇到了这个问题
Start-Process cmd /c -WindowStyle Hidden -Wait -Credential $credential    
    -ErrorAction SilentlyContinue;  

0 个答案:

没有答案