Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Adding domain user to local group

$
0
0

For a starter I'm trying to achieve as per topic with the following

#create local groups based on a file with (some group one, some group two,....)

$local = get-content '.\localg.txt'

Function AddLocal($localg){

     foreach($gp in $localg){

          $cn = [ADSI]"WinNT://$env:computername"

          $gp = $cn.Create("group","$lg")

          $gp.SetInfo()

     }

}

AddLocal($local)

groups get created but...

I tested

[ADSI]::Exist("WinNT://$env:computername/some group one")

I get $FALSE

[ADSI]::Exist("WinNT://some group one")

I get $TRUE

if I delete the group and create it in GUI I'm getting the opposite situation when testing if Exists which I don't understand as I was expecting computername/Some Group One to work

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles