Press J to jump to the feed. Press question mark to learn the rest of the keyboard shortcuts
View
Sort
Coming soon

I think it's Romainian but spelled wrong or google translated wrong.

Edit "Fratele" is brother

2

I'm trying to set up user folder redirection to our Fileserver, I've set the users Home Folder to K: and my remote server \\server.contoso.com\users\username. I've also set the group policy user -> Policies -> Windows Settings -> Folder Redirection -> Documents (Basic/Redirect to the user's home directory), Pictures (Follow the Documents folder), Music (Follow the Documents folder), Videos (Follow the Documents folder).

Pictures, Music, and Videos show up in the expected location on the file server however Documents does not show up, the server is 2016, the workstation is Win10.

I've also set a group policy to wait for the network at login, I've deleted the user profile on my test box.

GPResult shows this error: "Folder Redirection failed due to the error listed below. Cannot complete this function."

Event Log <System> shows: "Windows failed to apply the Folder Redirection settings. Folder Redirection settings might have its own log file."

Event Log <GroupPolicy>: does not have any useful errors

Has anyone ran into this before? Any ideas?

2
5 comments

The server is 2016, but is that also the domain functional level? Windows 10 has trouble with a functional level of 2008R2 due to UNC hardening to NETLOGON and SYSVOL. Just curious.

see more
Original Poster1 point · 4 days ago

the file server is 2016, AD is 2012R2 with functional level 2012R2

Do one or the other (redirect home folder in AD, or redirect in group policy) - do not do both.

The error you are seeing is usually due to a NTFS permissions issue on the root directory of the share you created.

see more
Original Poster1 point · 4 days ago

Ok, the results I'm seeing is setting the "Home Folder" in AD does not redirect the "Documents" folder on the user profile, hence the group policy.

3

I'm having a problem renaming my user accounts. Currently it's renaming but it renames using the previously used name vs the new name. I'm thinking the script is populating my $x variable prior to running set-aduser where it's updating givenName and surName with the new data.

#===================================================================================================
# Update User Info
#===================================================================================================

Foreach ($user in $ActiveUsers) {

    $2bUpdated = Get-ADUser -Identity $user.StudentID -Properties * -ErrorAction $ErrorActionPreference | 

    Where {($user.PrimaryEnrollmentSite -ne $_.office) -or ($user.StudentID -ne $_.displayname) -or ($user.StudentFirstName -ne $_.GivenName) -or `
    ($user.StudentLastName -ne $_.surName) -or (("Student" + "-" + $user.PrimaryEnrollmentSite + "-" + $user.Grade) -ne $_.description)} 

    foreach ($student in $2bUpdated) {


        Set-ADUSer -Identity $user.StudentID `
            -DisplayName $user.StudentID `
            -GivenName $user.StudentFirstName `
            -surName $user.StudentLastName`
            -Description ("Student" + "-" + $user.PrimaryEnrollmentSite + "-" + $user.Grade)

        LogWrite "$date3 Updating user info for: $user.studentID"

    }
}

#===================================================================================================
# Rename User Account
#===================================================================================================

Foreach ($user in $ActiveUsers) {

    $x = Get-ADUser $user.StudentID -Properties DistinguishedName,GivenName,Surname | select DistinguishedName,GivenName,Surname
    $2bRenamed = Get-ADUser -Identity $user.StudentID -Properties * -ErrorAction $ErrorActionPreference | Where {(($user.StudentFirstName + " " + $user.StudentLastName) -ne $x.DistinguishedName)} 
    $newname = ($x.GivenName + " " + $x.Surname)

    foreach ($student in $2bUpdated) {

        Rename-ADObject $x.DistinguishedName -NewName $newname
    }
}
3
4 comments
2 points · 5 days ago

I am on mobile so I am not positive on your formatting. I see a couple issues with your script. The first most likely is what is breaking. The other is a recommendation on cleaner scripts.

1) The distinguishedName property of an ADobject is going to be in the form of LDAP. CN=Joe Smith,OU=Students,DC=uni,DC=edu As an example. It must be the whole distinguishedName. You can’t just do the first part.

2) You nest foreach loops when you only have one object. Your first $user in $Activeuser is fine. However you do a get-aduser -identity which will return only one object. You then foreach over that object and reference $user in the higher level foreach. You don’t need the second foreach and if you do want/need the second foreach reference $student which is you object at that point and not $user.

see more
Original Poster2 points · 5 days ago

it's a little weird but my data source is a CSV, I use the first loop to filter down my list and the 2nd to modify the data of each user in the filtered data. The new data exists in the $user variable while the $student variable hold the old data. It's working now that I specify a single AD Server to update.

2 points · 5 days ago

Try adding these two lines at the start of your script:

Import-Module ActiveDirectory
Set-Location AD:\

It should force it to continue to use the same AD server for the entirety of the script, might be hitting a different server between calls

see more
Original Poster2 points · 5 days ago

Import-Module ActiveDirectory Set-Location AD:\

Ahhh good call, didn't even think of that. that fixed it!

2 points · 5 days ago

We use Solarwinds webhelpdesk, it's the best out there IMO, price is worth it.

You need one of these, for mosquitoes.

Laser engrave everything

Pro tip, if you gotta sail though a storm go stick all those kegs at the edge of the boom. You'll never get a lightning strike there.

see more

Sometimes true

8 points · 7 days ago

Meanwhile the bulldog is trying to figure out how to get to the beer.

5

I am 95% sure this site is full of fake accounts designed to get your subscription. I call bait and switch on POF.

5
4 comments

Use Powershell to export to XML or HTML

3

Not sure when this happened but now Experts-Exchange.com is just an annoying search result. Do any of you subscribe to their service?

3
13 comments

Good riddance. I run a Google search results blocker plug-in just to keep that one shitty site from showing up on any of my search results.

see more
Original Poster3 points · 11 days ago

Google search results blocker

That is a fantastic idea, today is a new day.

3

I have a csv with all my users, each at various buildings. In the csv each user is tagged with a building code such as BLDA, BLDB, BLDC... in AD the OUs are named "BuildingA", "BuildingB", "BuildingC". I need some help figuring out how to convert the abbreviated building code to my full path and used in my code below. Can it be done in my foreach loop or do I need to convert the data in the csv prior? I'm trying to not do that and stick with the standard OneRoster format.

users.csv

sourcedId orgSourcedIds username givenName familyName email
dc90000 BLDA dc-hunkelm Maxine Hunkel dc-hunkelm@dc.com
dc90002 BLDB dc-oliverq Oliver Queen dc-oliverq@dc.com
dc90003 BLDC dc-kallort Thom Kallor dc-kallort@dc.com
$BLDAOU = "OU=BuildingA,OU=Staff,OU=BatCave,DC=dc,DC=com"
$BLDBOU = "OU=BuildingB,OU=Staff,OU=BatCave,DC=dc,DC=com"
$BLDCOU = "OU=BuildingC,OU=Staff,OU=BatCave,DC=dc,DC=com"

$users = import-csv "../users.csv"

Foreach ($User in $Users)
{
    Try
    {
        Get-ADUser $User.username -ErrorAction Stop 
        Write-Host "$($User.username) is already in use."
    }
    Catch [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException]
    {
        Write-Warning "$($User.username) was not found in this domain! Creating user account:"
        New-ADUser `
                     -SamAccountName $user.username `
                     -Name ($user.givenName + " " + $user.familyName) `
                     -DisplayName $user.username `
                     -GivenName $user.givenName `
                     -surName $user.familyName`
                     -Description $user.role`
                     -Office $user.orgSourcedIds`
                     -Path "$OU,OU=Staff,OU=BatCave,DC=dc,DC=com"`
                     -EmailAddress ($user.username + "@dc.com") `
                     -UserPrincipalName ($user.username + "@dc.com") `
                     -Enabled $true `
                     -ChangePasswordAtLogon $false `
                     -PasswordNeverExpires  $true `
                     -AccountPassword (ConvertTo-SecureString $password -AsPlainText -force)
                     Write-Output "Created user $($user.SamAccountName), $_"
    }                

    Catch
    {
        Write-Error "War Were Declared"
    }
}
3
11 comments
2 points · 12 days ago

you'll have to put the switch inside of that foreach loop as well... maybe that isn't the optimal way of handling it. Another way is to create a hashtable and lookup the values:

$hashTable = @{
    "BLDA" = "OU=BuildingA,OU=Staff,OU=BatCave,DC=dc,DC=com"
    "BLDB" = "OU=BuildingB,OU=Staff,OU=BatCave,DC=dc,DC=com"
    "BLDC" = "OU=BuildingC,OU=Staff,OU=BatCave,DC=dc,DC=com"
}


$hashTable["BLDA"]
$someVariable = "BLDB"
$hashTable[$someVariable]
see more
Original Poster2 points · 12 days ago

$user.orgSourcedIds

Can the hash be associated to my $user.orgSourcedIds as I was with the Switch? My datasource has building codes that I am using to assign users to building OU's, join building groups and so on.

howdy gaz2600,

sure! look at how ihaxr did the last two lines. as long as $user.orgSourcedIds evaluates to one of the keys of the hashtable, it will work fine.

take care,
lee

see more
Original Poster2 points · 11 days ago

awesome, you guys rock! Learned a new tool!

Load more comments

o_0

What year is it?

see more
11 points · 12 days ago

1995-1999ish

I had so many zip disks back then, I loved how much storage they were capable of ... started my hoarding career early.

see more
7 points · 12 days ago

I had one but the dad of a friend of mine got a 1x CD burner, late nights at the college labs loading up on data and then dropping it off to be burned, which took hours.

8 points · 12 days ago

you know how much skill it takes to land a chopper like that?

how do bee's and mosquitoes get along?

I don't think an oven gets hot enough to really do that properly. You need to use a heat gun or a reflow oven, don't you?

see more
2 points · 13 days ago

I tried cooking my xbox 360 when it had the redring, just made it worse. had to toss it.

Trying to create a PowerShell script to auto create AD users based off data from multiple OneRoster formatted CSVs.

Is space more like Star Trek, Star Wars, or The Orville?

3 points · 17 days ago

Try one of the truckstops

u/gaz2600
My opinions are only valid during the time of posting and are subject to change just after posting.
Karma
3,177
Cake day
May 6, 2017
Trophy Case (3)
One-Year Club

reddit gold

Since January 2018

Verified Email

Cookies help us deliver our Services. By using our Services or clicking I agree, you agree to our use of cookies. Learn More.