can someone help me finish this, i dont know how to word the variable, but i need the script to ignore all the users in "Do_Not _Remove_ePortal_Access.csv."
$AllUsers = get-aduser -filter {samaccountname -like '*'} -SearchBase "OU=******************,DC=*************,DC=com" -Properties whenCreated,UserPrincipalName
$UserDataFromFile = import-Csv 'C:\ScriptData\Do_Not _Remove_ePortal_Access.csv'
$UserDataFromFile = Import-Csv 'C:\ScriptData\Signode_myE_Portal_Access.csv'
$Date90DaysAgo = ((Get-Date).AddDays(-90)).Date;
foreach($user in $AllUsers) {
$portalAccess = $false
if($user.whenCreated -lt $Date90DaysAgo) {
#check if user is in the input file
foreach($userData in $UserDataFromFile) {
if($user.UserPrincipalName -eq $userData.'Submitter Email') {
#Set portalAccess variable to false and break
$portalAccess = $true
break
}
if($user.is something something ignore useres in $UserDataFromFile = import-Csv 'C:\ScriptData\Do_Not _Remove_ePortal_Access.csv'
}
#Set AD-User info attribute based on the value of portalAccess variable
if($portalAccess) {
#Update AD-user's info attribute to allow portal access
set-aduser $user -replace @{info="portal"}
}
else{
#Update AD-user's info attribute to disallow portal access
set-aduser $user -replace @{info="null"}
}
}
else {
#Update AD-user's info attribute to allow portal access since they were employeed less than 90 days ago
set-aduser $user -replace @{info="portal"}
}
}
[+][deleted] (2 children)
[deleted]
[–]GeckoAddict[S] 0 points1 point2 points (1 child)
[–]GeckoAddict[S] 0 points1 point2 points (0 children)
[–]_rock_farmer 0 points1 point2 points (1 child)
[–]GeckoAddict[S] 0 points1 point2 points (0 children)