View Single Post
Old 03-06-2007   #4 (permalink)
Brandon Shell


 
 

Re: local user please

That looks like a cut/paste problem

That should be on the same line as the write-host.
Write-Host
"----------------------------------------------" -ForegroundColor gray
should be
Write-Host "--------------------" -ForegroundColor gray


--
Brandon Shell
---------------
Stop by my blog some time
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject
--------------------------------------

"frank" <frank@discussions.microsoft.com> wrote in message
news:72106A5A-4FCC-4882-B587-3389D0E16D6D@microsoft.com...
>I get an error
> You must provide a value expersion on the right-hand side of -f operator
> "---------"
> -Fo <<<< reground color gray
>
>
>
> "Brandon Shell" wrote:
>
>> Disclaimer... this was before the valid -whatif push by the dev team.
>>
>> I STRONGLY recommend using Jeffrey's should-process script noted here:
>> http://blogs.msdn.com/powershell/default.aspx
>>
>> --
>> Brandon Shell
>> ---------------
>> Stop by my blog some time
>> Blog: http://www.bsonposh.com/
>> PSH Scripts Project: www.codeplex.com/psobject
>> --------------------------------------
>>
>> "Brandon Shell" <tshell.mask@gmail.com> wrote in message
>> news:eh1l3LBYHHA.4440@TK2MSFTNGP03.phx.gbl...
>> > Some Functions I wrote for this... they all use WinNT instead of LDAP
>> > so
>> > you can run locally.
>> >
>> > function add-User{
>> > Param([string]$user,[string]$password,[string]$server)
>> > If(!($server)){$server = get-content env:COMPUTERNAME}
>> > $tUser = [ADSI]("WinNT://$server,computer")
>> > $newuser = $tUser.psbase.children.add("$user","user")
>> > $newuser.psbase.invoke("SetPassword",$password)
>> > $newuser.psbase.CommitChanges()
>> > }
>> >
>> > function add-AdminUser{
>> > Param([string]$user,[string]$password,[string]$server)
>> > If(!($server)){$server = get-content env:COMPUTERNAME}
>> > $tUser = [ADSI]("WinNT://$server,computer")
>> > $newuser = $tUser.psbase.children.add("$user","user")
>> > $newuser.psbase.invoke("SetPassword",$password)
>> > $newuser.psbase.CommitChanges()
>> > $ary = @()
>> > $ary += $newuser.psbase.path
>> > # Getting Group and Adding User
>> > $g = [ADSI]("WinNT://$server/Administrators,group")
>> > $g.psbase.invoke("add",$ary)
>> > }
>> >
>> > function add-UsertoGroup{
>> > Param([string]$user,[string]$group,[string]$server)
>> > If(!($server)){$server = get-content env:COMPUTERNAME}
>> > Write-Host ""
>> > Write-Host "Adding User [$user] to group [$group]"
>> > Write-Host
>> > "----------------------------------------------" -ForegroundColor gray
>> > $ary = @()
>> > $srv = [ADSI]("WinNT://$server,computer")
>> > $u = [ADSI]("WinNT://$server/$User,User")
>> > $ary += $u.psbase.path
>> > # Getting Group and Adding User
>> > $g = [ADSI]("WinNT://$server/$group,group")
>> > $g.psbase.invoke("add",$ary)
>> > #if(!($g.psbase.invoke("isMember",$ary)))
>> > {$g.psbase.invoke("add",$ary)}
>> > #else {Write-Host "User already a Member" -ForegroundColor yellow}
>> > # Checking Group for User
>> > #if(!($g.psbase.invoke("IsMember",$ary))){Write-Host "User Add
>> > Failed!" -ForegroundColor Red}
>> > #else{Write-Host "User Added." -ForegroundColor green}
>> > Write-Host "If no Exception... User Added" -ForegroundColor Green
>> > }
>> >
>> > --
>> > Brandon Shell
>> > ---------------
>> > Stop by my blog some time
>> > Blog: http://www.bsonposh.com/
>> > PSH Scripts Project: www.codeplex.com/psobject
>> > --------------------------------------
>> >
>> > "frank" <frank@discussions.microsoft.com> wrote in message
>> > news:50ABD76E-C714-47A7-8032-4332023897C2@microsoft.com...
>> >> Sorry for the repost but does any one know how to create a local user
>> >> in powershecll
>> >

>>
>>


My System SpecsSystem Spec