User Profile
NZScottie
Copper Contributor
Joined 6 years ago
User Widgets
Recent Discussions
Re: Need to Replace non english characters with english alphabets
Hi Satish_krishna91 Give the following a try. It should be easy to modify with the rest of the characters you require to replace. I have written it on the fly so the syntax may not be quite correct. Make sure you run this on a small subset of users or better still some test users before running in production. # Filter this down to a small set to test with before running over all users in domain. $ADUsers = Get-ADUsers -filter * foreach ($ADUser in $ADUsers) { $NewUPN = $ADUser.UserPrincipalName switch -Regex -CaseSensitive ($ADUser.UserPrincipalName) { 'Ä' { $NewUPN = $NewUPN -replace 'Ä','A' } 'ä' { $NewUPN = $NewUPN -replace 'ä','a' } 'Ë' { $NewUPN = $NewUPN -replace 'Ë','E' } 'ë' { $NewUPN = $NewUPN -replace 'ë','e' } } $ADUser | Set-ADUser -UserPrincipalName $NewUPN } Let me know how you get on.2.7KViews0likes0CommentsRe: PowerShell to find and copy a file with wildcard
_OSD_ I would try something like the code below, assuming there are multiple profile directories and you want to replicate that in the destination directory. $SourceDir = 'C:\Users\StandardUser\AppData\Roaming\Mozilla\Firefox\Profiles' $DestinationDir = 'C:\FireFox\' $FileNameAndExtension = 'places.sqlite' $SQLiteFiles = Get-ChildItem -Path "$SourceDir*\$FileNameAndExtension" foreach($SQLiteFile in $SQLiteFiles){ $ParentFolder = $SQLiteFile.Directory -replace [regex]::Escape("$SourceDir") New-Item -ItemType Directory -Name "$DestinationDir$ParentFolder" Copy-Item -Path $SQLiteFile -Destination "$DestinationDir$ParentFolder" } Hopefullly I have understood what you were after. 😉2.7KViews0likes0CommentsRe: Move and Rename Computer Object Despite Slow DC Syncronization
ssstier I have come across similar behaviour in a few of my scripts in multi domain controller environments with delayed replication timings around sites. I found that I have to explicitly name the domain controller to which I am making the calls. This way I control the domain controller my powershell calls are being made against and know that when making subsequent queries the domain controller has the 'most up-to-date version' of the object (before full replication has taken place). In your example, I would try getting the DC that the computer being renamed is communicating with and pass that through to the -server parameter in the Get-ADComputer command and see if that helps reduce the amount of strange behaviour you experience. Hope this makes sense and helps set you in the right direction for having a more stable script.2.1KViews0likes0Comments
Groups
Recent Blog Articles
No content to show