ok it not geetting an error and I really sorry to bug you but nothing happens
I type in ./user.ps1
just shows up back at ps prompt
I try ./user.ps1 username password group server
and evrything in between and nothing happens
plase help
"Brandon Shell" wrote:
> Again.. same problem
cut/paste is evil
>
> Just make sure any reference to -foregroundcolor is on the same line as
> write-host. It is a parameter.
>
> This is the line I think is erroring
> #if(!($g.psbase.invoke("IsMember",$ary))){Write-Host "User Add
> Failed!" -ForegroundColor Red}
>
> This is just a comment so you can delete the whole line or at least make it
> on one line
>
> --
> 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:667FD8FA-C74D-47FA-A117-83B8D9DF1B40@microsoft.com...
> > different error now
> >
> > Incomplete string taken
> > +F <<< ailed -foregroundcolor red
> >
> > I type in ./new.ps1 testuser 1233456 grouop server
> >
> >
> >
> > "Brandon Shell" wrote:
> >
> >> 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
> >> >> >
> >> >>
> >> >>
> >>
> >>
>
>