Hi
I am trying to create the ID using pslink.exe in power CLI, i am getting followig error message
Server sent command exit status 2
usage: useradd [-u uid [-o]] [-g group] [-G group,...]
[-d home] [-s shell] [-c comment] [-m [-k template]]
[-f inactive] [-e expire ] [-p passwd] [-M] [-n] [-r] [-l] nam
useradd -D [-g group] [-b base] [-s shell]
[-f inactive] [-e expire ]
This is the script
Get-VMHost | %{
$User = "root"
$Pswd = "xxxxxx"
$plink = "C:\Progra~1\PuTTY\plink.exe"
$plinkoptions = " -v -batch -pw $Pswd"
$cmd1 = ' useradd -u 10001 -G wheel -s /bin/bash -d /home/xxxxx -m -p xxxxxx -c "xxxxxx" xxxxxxx'
$remoteCommand = '"'+ $cmd1 +'"'
$command = $plink + " " + $plinkoptions + " " + $User + "@" + $_.NAME + " " + $remoteCommand
$msg = Invoke-Expression -command $command
}
Kindly help on this
Why don't you use the New-VMHostAccount cmdlet? Something like:
New-VMHostAccount -Id 1001 -Password TopSecret -Description 'User 1001' -UserAccount -AssignGroups wheel -GrantShellAccess
Why don't you use the New-VMHostAccount cmdlet? Something like:
New-VMHostAccount -Id 1001 -Password TopSecret -Description 'User 1001' -UserAccount -AssignGroups wheel -GrantShellAccess
excellent it got works.... by the way can u tell me anything wrong in plink command, looks like space or special character issue but i couldn't able to identify
sorry actually the answer is helpful answer, i am looking for doing it on bulk of servers so i guess it won't be possible by using your command, can u tell me how i can achive?
Hi,
can you try your command in the way i did ?
http://psvmware.wordpress.com/2012/04/13/esxi-filesystem-disk-usage-script/
$str1=’c:\plink.exe -v -pw ”v53HYfsd#$%$%^^&*” -l root ‘
$str2='useradd -u 10001 -G wheel -s /bin/bash -d /home/xxxxx -m -p xxxxxx -c "xxxxxx" xxxxxxx'
$esxhost=”‘”+'esx_host_name'+”‘”
$command=$str1+$esxhost+$str2
Invoke-Expression -Command $command
And let me know if this works for you ?
Greg