Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. [CmdletBinding()]
  2. Param(
  3. [Parameter(Mandatory=$True,Position=0)]
  4. [alias("user","name")]
  5. [string]
  6. $UserName,
  7. [Parameter(Mandatory=$False,Position=1)]
  8. [string]
  9. $ComputerName = 'localhost',
  10. [Parameter(Mandatory=$False)]
  11. [string]
  12. $Domain = 'WORKGROUP'
  13. )
  14.  
  15. $Group = 'Administrators'
  16.  
  17. # Please be warned. The syntax of [ADSI] is CASE SENSITIVE!
  18. $target=[ADSI]"WinNT://$ComputerName/$Group,group"
  19. $target.psbase.Invoke("Add",([ADSI]"WinNT://$Domain/$UserName").path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement