{"id":3319,"date":"2021-06-04T14:01:35","date_gmt":"2021-06-04T13:01:35","guid":{"rendered":"https:\/\/www.dbonline.se\/?p=3319"},"modified":"2021-06-07T13:35:38","modified_gmt":"2021-06-07T12:35:38","slug":"changing-the-preferred-language-in-office365-in-bulk","status":"publish","type":"post","link":"https:\/\/www.dbonline.se\/index.php\/2021\/06\/04\/changing-the-preferred-language-in-office365-in-bulk\/","title":{"rendered":"Changing the preferred language in office365 in BULK"},"content":{"rendered":"\n<p>If you have office365 with active directory sync here is a simple way of changing the AD users preferred language in bulk!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$UpnPath = \"C:\\OfficeLanguageScript\\UsersToCheck.txt\"\n$DoneUpnPath = \"C:\\OfficeLanguageScript\\DoneUsers.txt\"\n$UpnPath = \"C:\\OfficeLanguageScript\\UsersToCheck.txt\"\n$C = Get-ADUser -Filter * -SearchBase 'OU=SWE,DC=domain,DC=com' | Select-Object -Property SamAccountName | Out-String\nWrite-Host $C\n#Creates file with all users UPN\nif (!(Test-Path $UpnPath))\n{\n   New-Item -Path \"C:\\OfficeLanguageScript\\\" -Name \"UsersToCheck.txt\" -ItemType \"file\" -Value $C\n   Write-Host \"Created new file and text content added\"\n}\nelse\n{\n  Remove-Item \u2013path $UpnPath\n  New-Item -Path \"C:\\OfficeLanguageScript\\\" -Name \"UsersToCheck.txt\" -ItemType \"file\" -Value $C\n  Write-Host \"File already exists so it was cleared and filled with new data\"\n}\n(Get-Content $UpnPath | Select-Object -Skip 3) | Set-Content \"C:\\OfficeLanguageScript\\UsersToCheck.txt\"\nWrite-Host \"Removing first three rows\"\n(Get-Content $UpnPath | Foreach {$_.TrimEnd()}) | Set-Content \"C:\\OfficeLanguageScript\\UsersToCheck.txt\"\nWrite-Host \"removing trailing space of file\"\n(Get-Content $UpnPath | ? {$_.trim() -ne \"\" }) | Set-Content \"C:\\OfficeLanguageScript\\UsersToCheck.txt\"\nWrite-Host \"removing trailing empty lines\"\n#Check if there is a file with done users\nif (!(Test-Path $DoneUpnPath))\n{\n   New-Item -Path \"C:\\OfficeLanguageScript\\\" -Name \"DoneUsers.txt\" -ItemType \"file\"\n   Write-Host \"Created new DoneUsers file and text content added\"\n}\n#Compare files\n$strReference = Get-Content $UpnPath\n$strDifference = Get-Content $DoneUpnPath\n#If null array.... ffs....\nif ($strReference -eq $null) { $strReference = \"\" }\nif ($strDifference -eq $null) { $strDifference = \"\" }\n#Removes empty inputs\n$strReference = $strReference.Where({ $_ -ne \"\" })\n$strDifference = $strDifference.Where({ $_ -ne \"\" })\n#Compares the lists\n$users = Compare-Object $strReference $strDifference\nWrite-Host \"Users to change language on\"\nWrite-Host $users.InputObject\nforeach ($user in $users.InputObject)\n{\n  Set-ADUser $user \u2013replace @{PreferredLanguage=\"sv-SE\"}\n  Add-Content $DoneUpnPath $user\n}  <\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have office365 with active directory sync here is a simple way of changing the AD users preferred language in bulk!<\/p>\n","protected":false},"author":1,"featured_media":3333,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[4,5],"tags":[],"class_list":["post-3319","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-it","category-jobb"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.dbonline.se\/wp-content\/uploads\/2021\/06\/kisspng-essential-powershell-windows-management-framework-shell-v-power-5b3935d48f1a28.5089086515304759885862.png?fit=512%2C512&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8vDvB-Rx","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.dbonline.se\/index.php\/wp-json\/wp\/v2\/posts\/3319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbonline.se\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbonline.se\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbonline.se\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbonline.se\/index.php\/wp-json\/wp\/v2\/comments?post=3319"}],"version-history":[{"count":7,"href":"https:\/\/www.dbonline.se\/index.php\/wp-json\/wp\/v2\/posts\/3319\/revisions"}],"predecessor-version":[{"id":3335,"href":"https:\/\/www.dbonline.se\/index.php\/wp-json\/wp\/v2\/posts\/3319\/revisions\/3335"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dbonline.se\/index.php\/wp-json\/wp\/v2\/media\/3333"}],"wp:attachment":[{"href":"https:\/\/www.dbonline.se\/index.php\/wp-json\/wp\/v2\/media?parent=3319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbonline.se\/index.php\/wp-json\/wp\/v2\/categories?post=3319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbonline.se\/index.php\/wp-json\/wp\/v2\/tags?post=3319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}