Register
: :
Login
Home
News
Forums
Scripts
User Groups
Resources
About
Forums
Search
Members
Unanswered
Active Topics
Forums
>
Using PowerShell
>
Active Directory
Verify Credentials and Validate AD Group Membership
Last Post 21 Jul 2010 12:17 PM by
Shay Levy
. 2 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
tvv1974
New Member
Posts:2
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.
tvv1974
New Member
Posts:2
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 Levy
PowerShell MVP, Admin
Veteran Member
Posts:1362
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.
Using PowerShell
--General PowerShell
--Books, Tools, and Videos
--Exchange Server
--Active Directory
--System Center Family
--Non-Microsoft Products
--SharePoint
--SQL Server
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Forums
>
Using PowerShell
>
Active Directory
Active Forums 4.3
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2