header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Verify Credentials and Validate AD Group Membership
Last Post 21 Jul 2010 12:17 PM by Shay Levy. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
tvv1974User is Offline
New Member
New Member
Posts:2
Avatar

--
21 Jul 2010 09:15 AM
    I am writing a script which will create backup schedules in 2008/2008R2. I am using get-credentials cmdlet and storing in a $cred variable and using $cred later in the script to run the scheduled jobs.

    While the script is running fine, there are few missing things like verification and validation. I want to know how we can add these into the script for ex.: I want to first validate if the credential provided was correct and was Successfully authenticated by AD and once the credentials are validated, the script should look for a mandatory users group membership information, i.e. if the user is a member of US Admins group, only then proceed with the script else terminate with an intuitive error message. Can this be done? if so can you provide me some assistance here.
    tvv1974User is Offline
    New Member
    New Member
    Posts:2
    Avatar

    --
    21 Jul 2010 09:41 AM
    Here is a snippet of my code for which i want to add authentication and authorization mechanism

    #Gets the backup scheduler credentials from the user
    "Enter Credentials of the RMAD Backup Account in the format"
    "Domain\User"
    Write-host
    $cred=get-credential
    #create an array of Domain Controllers by reading from a text file
    $dclist=get-content DCListing.txt

    #Create an array of RMAD Collections
    $col="Daily","Weekly","Monthly","Adhoc"

    #Looping through the RMAD collections and adding the Domain Controllers to each collection
    #and checking empty spaces or null value in the dclist.txt file

    #Define iteration variables
    $i=0
    $j=0

    foreach($objitem in $col)
    {
    new-rmadcollection -name $col[$i]
    foreach($objitem2 in $dclist)
    {
    if($dclist -eq '') {}
    Elseif($dclist -eq $null) {}
    Else{add-rmadcollectionitem -Collection $col[$i] -DomainController $dclist[$j]}
    $j++
    }
    $j=0
    $i++
    }

    #Set the date and time for run Backup Schedules - Modify the date and time accordingly
    $date1="4/1/2009 9:00:00 AM"
    $date2="4/1/2009 9:00:00 PM"


    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    21 Jul 2010 12:17 PM
    Check this script: Test-ADCredentials http://poshcode.org/1393

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer