Service Manager - Subscription templates sends e-mail in wrong language
Import-Module smlets ; Add-PSSnapIn SMCmdletSnapIn ;
#Delete the existing data from the CSV Clear-Content -Path "E:SMAdminCSVUsers.csv"
#retrieve all users from the CMDB and cycle through them
$users = (get-scsmclass Microsoft.AD.User$ | get-scsmobject)
foreach ($user in $users)
{
$UserName = $user.UserName #get the username, used to identify the person
$Domain = $user.Domain #get the domain, this is required for a CSV import
$ID = $user.ID #get the users guid, we will use this to create the ID for the settings object $setPref = 'Pref.' #used as a prefix for the localsetting object id
$setID = $setPref,$ID
$setID = [string]::join('',$setID) #combine the users guid and Pref. to make the id for localesettings
if ($user.City -like "Shanghai") {$timezone = 'China Standard Time'}
elseif ($user.City -like "Dhaka") {$timezone = 'Central Asia Standard Time'}
else {$timezone = 'W. Europe Standard Time'}
$locale = '1033' #setting the locale, in this case it's English (United States)
$data = $UserName, $Domain, $setID, $timezone, $locale #put it all into an array
[string]::join(',',$data) | ForEach-Object {Add-Content -Value $_ -Path "E:SMAdminCSVUsers.csv"}; #convert the array to a string and append to the csv
}
#once all users have been added to the csv, import it into the CMDB using the xml mapping file.
Import-SCSMInstance -DataFileName "E:SMAdminCSVUsers.csv" -FormatFileName "E:SMAdminCSVUserImport.xml"
#Remove any automatically created localization settings, the script has create new ones for everybody
get-scsmclass System.UserPreference.Localization$ | get-scsmobject -filter {DisplayName -notlike "%-%"} | remove-scsmobject -force
Remove-PSSnapIn SMCmdLetSnapIn;
Remove-Module smlets;