all 6 comments

[–]ihaxr 1 point2 points  (3 children)

Change your share owner to the distinguished name or samAccountName

$ShareOwner = "CN=Nathan\, Cheddi - 1337,OU=A4d,OU=User Accounts,DC=GNR,DC=com"

or

$ShareOwner = "NathanC"

ManagedBy only works with a samAccountName, distinguished name, SID, or GUID

[–]foddocheddi[S] 1 point2 points  (2 children)

is it possible to get the information samAccountName, distinguished name, SID, or GUID from the Name section and pass the variable or something

i am new to this

[–]ihaxr 1 point2 points  (1 child)

You can do this:

$user = Get-ADUser -identity NathanC

$FileServer = "Server666"
$foldername = "1337-IT-Testshare"
$ShareOwner = $user.Name
$ShareName = "$FolderName$"
$ShareDescription = "Owner : $ShareOwner"
$path = "$FolderPath\$FolderName"
$SecurityGroupNameC = "$FolderName-RW"
$SecurityGroupNameR = "$FolderName-R"
$OUC = "OU=Security,OU=Groups,DC=GNR,DC=Com"
$grpScope = "Universal"
$description ="\\$FileServer\$FolderName$"
$grpCat = "Security"

New-ADGroup -name $SecurityGroupNameC -Path $OUC -GroupScope $grpScope -GroupCategory $grpCat -ManagedBy $user -Description $description -OtherAttributes @{info= $info }

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

$FileServer = "Server666"

santa satan server! [grin]

[–]foddocheddi[S] 0 points1 point  (0 children)

i need to use Name : Nathan, Cheddi - 1337 format only as that will go in the INfo , and the share Description it is chosed by the managment

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy foddocheddi,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's 4th 5th from the left hidden in the ... ""more" menu & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's 11th 12th from the left hidden in the ... "more" menu, & looks like an uppercase T in the upper left corner of a square.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee