I am in need of a powershell script that will read users home directory path in AD and then input that same path into the otherpager attribute, but change the formatting from a UNC path to a CIFS path.
Here is what I got so far but I can't get it to work.
This gets the list of users that I need.
Get-ADUser -Filter {(objectCategory -eq "User") -and (userPrincipalName -notlike "*@students.uwc.edu") -and (userPrincipalName -notlike "wsh-*@uwc*") -and (userPrincipalName -notlike "shb-*@uwc*") -and (userPrincipalName -notlike "wak*@uwc*") -and (userPrincipalName -notlike "rln*@uwc*") -and (userPrincipalName -notlike "rck*@uwc*") -and (userPrincipalName -notlike "mth*@uwc*") -and (userPrincipalName -notlike "msf*@uwc*") -and (userPrincipalName -notlike "cstudent*@uwc*") -and (userPrincipalName -notlike "fdl*@uwc*") -and (userPrincipalName -notlike "brb*@uwc*") -and (userPrincipalName -notlike "brn*@uwc*") -and (userAccountControl -notlike "ACCOUNTDISABLE") -and (homeDirectory -like "*")} -Properties userPrincipalName, homeDirectory, homeDrive, otherPager, pager, telexNumber | Select-Object userPrincipalName, homeDirectory, homeDrive, @{n='OtherPager';e={$_.OtherPager -join '; '}}, @{n='pager';e={$_.pager -join '; '}}, @{n='telexNumber';e={$_.telexNumber -join '; '}} | export-csv -useculture -notype c:\_Ldap\userPrincipalName022.csv
And this is where I need help with the syntax.
Select-Object userPrincipalName, homeDirectory, homeDrive, @{n='OtherPager';e={$_.OtherPager -join '; '}}, @{n='pager';e={$_.pager -join '; '}}, @{n='telexNumber';e={$_.telexNumber -join '; '}}
ForEach-Object {Set-ADObject -Identity $_.userPrincipalName `
-Replace @{OtherPager="$($_.homeDiretory -replace "\\","//")"} | export-csv -useculture -notype c:\_Ldap\userPrincipalName-test.csv
I would prefer to have a script that would do this via variables that could then be modified to be a CIFS path..