daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest May 22nd, 2014 178 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function add_user_to_iis_group([Parameter(Mandatory=$true)]$username)
  2. {
  3.     $computergroup = [ADSI]("WinNT://localhost,computer")
  4.     $admins = $computergroup.psbase.children.find("IIS_IUSRS")
  5.    
  6.     foreach ($member in $admins.psbase.Invoke("Members")) {
  7.         $member_name = $member.GetType().InvokeMember("Name", 'GetProperty', $null, $member, $null)
  8.         if ($member_name -eq $username) {
  9.             Write-Host $username "already in this group."
  10.             return
  11.         }
  12.     }
  13.     $admins.Add("WinNT://$username")
  14. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top