Changing the preferred language in office365 in BULK

Changing the preferred language in office365 in BULK

If you have office365 with active directory sync here is a simple way of changing the AD users preferred language in bulk!

$UpnPath = "C:\OfficeLanguageScript\UsersToCheck.txt"
$DoneUpnPath = "C:\OfficeLanguageScript\DoneUsers.txt"
$UpnPath = "C:\OfficeLanguageScript\UsersToCheck.txt"
$C = Get-ADUser -Filter * -SearchBase 'OU=SWE,DC=domain,DC=com' | Select-Object -Property SamAccountName | Out-String
Write-Host $C
#Creates file with all users UPN
if (!(Test-Path $UpnPath))
{
   New-Item -Path "C:\OfficeLanguageScript\" -Name "UsersToCheck.txt" -ItemType "file" -Value $C
   Write-Host "Created new file and text content added"
}
else
{
  Remove-Item –path $UpnPath
  New-Item -Path "C:\OfficeLanguageScript\" -Name "UsersToCheck.txt" -ItemType "file" -Value $C
  Write-Host "File already exists so it was cleared and filled with new data"
}
(Get-Content $UpnPath | Select-Object -Skip 3) | Set-Content "C:\OfficeLanguageScript\UsersToCheck.txt"
Write-Host "Removing first three rows"
(Get-Content $UpnPath | Foreach {$_.TrimEnd()}) | Set-Content "C:\OfficeLanguageScript\UsersToCheck.txt"
Write-Host "removing trailing space of file"
(Get-Content $UpnPath | ? {$_.trim() -ne "" }) | Set-Content "C:\OfficeLanguageScript\UsersToCheck.txt"
Write-Host "removing trailing empty lines"
#Check if there is a file with done users
if (!(Test-Path $DoneUpnPath))
{
   New-Item -Path "C:\OfficeLanguageScript\" -Name "DoneUsers.txt" -ItemType "file"
   Write-Host "Created new DoneUsers file and text content added"
}
#Compare files
$strReference = Get-Content $UpnPath
$strDifference = Get-Content $DoneUpnPath
#If null array.... ffs....
if ($strReference -eq $null) { $strReference = "" }
if ($strDifference -eq $null) { $strDifference = "" }
#Removes empty inputs
$strReference = $strReference.Where({ $_ -ne "" })
$strDifference = $strDifference.Where({ $_ -ne "" })
#Compares the lists
$users = Compare-Object $strReference $strDifference
Write-Host "Users to change language on"
Write-Host $users.InputObject
foreach ($user in $users.InputObject)
{
  Set-ADUser $user –replace @{PreferredLanguage="sv-SE"}
  Add-Content $DoneUpnPath $user
}  

Bulk changing OneDrive language of users

We are a daughter company located in another country than our parent company which means that our shared office 365 tenant has a default language that we don’t daily use.

To not have to change the language settings of every user individually we can use the following script to bulk edit the users based on OU membership.
NOTE! This is only for the language settings for example the built in excell in onedrive. This does not change the preferred office365 language.

If you have any questions of how it works, contact me.

$UpnPath = "C:\OneDriveLanguageScript\UsersToCheck.txt"
$DoneUpnPath = "C:\OneDriveLanguageScript\DoneUsers.txt"
$UpnPath = "C:\OneDriveLanguageScript\UsersToCheck.txt"
$SiteURL = "https://tehoc-admin.sharepoint.com/"
$ODUrl = "https://tehoc-my.sharepoint.com/personal/"
$Locale = "1053"

#User Name Password to connect 
$AdminUserName = "username@domain.com"
$AdminPassword = "apppass" #App Password
 
#Prepare the Credentials
$SecurePassword = ConvertTo-SecureString $AdminPassword -AsPlainText -Force
$creds = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminUserName, $SecurePassword

$C = Get-ADUser -Filter "userPrincipalName -like '*'" -SearchBase 'OU=SWE,DC=domain,DC=com' | Select-Object -Property UserPrincipalName | Out-String

#Creates file with all users UPN

if (!(Test-Path $UpnPath))
{
   New-Item -Path "C:\OneDriveLanguageScript\" -Name "UsersToCheck.txt" -ItemType "file" -Value $C
   Write-Host "Created new file and text content added"
}
else
{
  Remove-Item –path $UpnPath
  New-Item -Path "C:\OneDriveLanguageScript\" -Name "UsersToCheck.txt" -ItemType "file" -Value $C
  Write-Host "File already exists so it was cleared and filled with new data"
}

(Get-Content $UpnPath | Select-Object -Skip 3) | Set-Content "C:\OneDriveLanguageScript\UsersToCheck.txt"
Write-Host "Removing first three rows"

(Get-Content $UpnPath | Foreach {$_.TrimEnd()}) | Set-Content "C:\OneDriveLanguageScript\UsersToCheck.txt"
Write-Host "removing trailing space of file"

(Get-Content $UpnPath | ? {$_.trim() -ne "" }) | Set-Content "C:\OneDriveLanguageScript\UsersToCheck.txt"
Write-Host "removing trailing empty lines"

#Check if there is a file with done users

if (!(Test-Path $DoneUpnPath))
{
   New-Item -Path "C:\OneDriveLanguageScript\" -Name "DoneUsers.txt" -ItemType "file"
   Write-Host "Created new DoneUsers file and text content added"
}

#Compare files

$strReference = Get-Content $UpnPath
$strDifference = Get-Content $DoneUpnPath

#If null array.... ffs....
if ($strReference -eq $null) { $strReference = "" }
if ($strDifference -eq $null) { $strDifference = "" }

#Removes empty inputs
$strReference = $strReference.Where({ $_ -ne "" })
$strDifference = $strDifference.Where({ $_ -ne "" })

#Compares the lists
$users = Compare-Object $strReference $strDifference

Write-Host "Users to change language on"
Write-Host $users.InputObject

#Connect msol service
Connect-SPOService -Url $SiteURL -Credential $creds

#Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.UserProfiles.dll"

foreach ($user in $users.InputObject)
{
  #Building user ODrive Full Url
  Write-Host "Building ODrive Full Url for $user" -ForegroundColor Yellow
  $ODriveFullUrl = $ODUrl +  $user.Replace("@","_").replace('.','_')
  Write-Host $ODriveFullUrl
  
  #Adding Admin access to user OneDrive
  Write-Host "Adding Admin access to $user OneDrive" -ForegroundColor Yellow
  Set-SPOUser -Site $ODriveFullUrl -LoginName $creds.UserName -IsSiteCollectionAdmin $true | Out-Null

  #Bind to OD4B Site and change locale
  Write-Host "Changing Locale for $user" -ForegroundColor Yellow 
  $spocreds = [Microsoft.SharePoint.Client.SharePointOnlineCredentials]::new($Creds.UserName,$creds.Password)
  $Context = New-Object Microsoft.SharePoint.Client.ClientContext($ODriveFullUrl)
  $return = $Context.Credentials = $spocreds
  $Context.ExecuteQuery()
  $Context.Web.RegionalSettings.LocaleId = $Locale                  
  $Context.Web.Update()
  $Context.ExecuteQuery()
  Write-Host $Context
    
  #Removing Admin access from User OneDrive
  Write-Host "Removing Admin access from $upn OneDrive" -ForegroundColor Green
  Set-SPOUser -Site $ODriveFullUrl -LoginName $creds.UserName -IsSiteCollectionAdmin $false | Out-Null
  Add-Content $DoneUpnPath $user
}

Lubuntu mute/unmute button problem

I noticed a problem with my keyboards mute/unmute button. It seems that it only mutes, but the solution is simple.
Do the following, edit the .config/openbox/lubuntu-rc.xml with nano.

sudo nano .config/openbox/lubuntu-rc.xml

scroll down untill you see this

<!-- Keybinding for Volume management -->
  <keybind key="XF86AudioRaiseVolume">
    <action name="Execute">
      <command>amixer -q sset Master 3%+ unmute</command>
    </action>
  </keybind>
  <keybind key="XF86AudioLowerVolume">
    <action name="Execute">
      <command>amixer -q sset Master 3%- unmute</command>
    </action>
  </keybind>
  <keybind key="XF86AudioMute">
    <action name="Execute">
      <command>amixer -q sset Master toggle</command>
    </action>
  </keybind>

and type in the following: -D pulse after the -q so it looks like this

<!-- Keybinding for Volume management -->
  <keybind key="XF86AudioRaiseVolume">
    <action name="Execute">
      <command>amixer -q -D pulse sset Master 3%+ unmute</command>
    </action>
  </keybind>
  <keybind key="XF86AudioLowerVolume">
    <action name="Execute">
      <command>amixer -q -D pulse sset Master 3%- unmute</command>
    </action>
  </keybind>
  <keybind key="XF86AudioMute">
    <action name="Execute">
      <command>amixer -q -D pulse sset Master toggle</command>
    </action>
  </keybind>

reboot and done!

Enabling hibernation on Lubuntu

This is a simple guide to enable hibernation on Lubuntu.
It took me eight hours to fix, hopefully it wont take you this long.

  1. Make sure you have a swap partition! NOTE SWAP PARTITION it’s much simpler.
    There are multiple guides online to setup the swap area,
    see this as an example: https://help.ubuntu.com/community/SwapFaq
  2. Enable the hibernate buttons by editing this file:
    sudo nano /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla[Disable hibernate by default in upower]
    Identity=unix-user:*
    Action=org.freedesktop.upower.hibernate
    ResultActive=no[Disable hibernate by default in logind]
    Identity=unix-user:*
    Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
    ResultActive=noto ”yes”
  3. We will be using s2disk for our hibernation, install it with he following command:
    aptget install uswsusp

    If the configuration wizard doesn’t start automatically type:
    sudo dpkg-reconfigure uswsusp

  4. Now we need to tell the system to use s2disk so do the following:
    cp /lib/systemd/system/systemd-hibernate.service /etc/systemd/system/
    cp /lib/systemd/system/systemd-hybrid-sleep.service /etc/systemd/system/

    And edit the /etc/systemd/system/systemd-hibernate.service

    [Service]
    Type=oneshot
    ExecStart=/bin/bash /opt/sleepscripts/s2disk.sh
    And /etc/systemd/system/systemd-hybrid-sleep.service
    [Service]
    Type=oneshot
    ExecStart=/bin/bash /opt/sleepscripts/s2both.sh
  5. Restart, and it should work

GDPR, tandlöst för privatpersoner

GDPR, tandlöst för privatpersoner

GDPR (General Data Protection Regulation) som blev lag den 25 maj 2018 är en lag vars syfte var att privatpersoner skulle få bättre kontroll över sina personuppgifter.
GDPR tillåter dock undantag för stat och myndighet samt att GDPR inte bryter mot existerande lagar.
Detta ger oss följande problem, offentlighetsprincipen och tryckfrihetsförordningen som är skyddad av grundlag.

Offentlighetsprincipen: https://lagen.nu/begrepp/Offentlighetsprincipen

Tryckfrihetsförordningen: https://lagen.nu/1949:105

All information om dig som du uppger till skatteverket är i princip offentliga uppgifter.
Dessa uppgifter är tex. var du bor, civilstatus samt vad du har i skatt (räkna bakåt och man kan beräkna vad du tjänar)
Dessa kan företag köpa av skatteverket och publicera genom att hänvisa till tryckfrihetsförordningen.

Detta kommer förstärka skatteverket som huvudsaklig leverantör av persondata.
Vilka företag har det just nu svettigt? Inga av dem i Sverige man ville sätta dit.
De som har det jobbigast just nu är små privata revisionsbyråer, lönekontor och HR avdelningar som måste kartlägga hur och var all persondata lagras samt sätta upp rutiner för hanterandet av dessa.

Vilka tjänar på det? Skatteverket och GDPR konsulter.

För att verkligen kunna reda ut och sätta press på oseriösa aktörer kan ett prejudicerande dom behövas.

Konfigrera switchar från läsplattan / varför det är viktigt med enable lösenord

En kul grej som jag har velat testa är om det går att konfigurera switchar från en tablet (läsplatta) med seriell kabel.
Och det går!

Jag har följande setup:

En USB A hona till en micro USB kontakt

 

 

 

 

 

 

 

 

 

 

 

 

 

 

En usb till seriell adapter

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Sedan var det bara att testa med en lämplig programvara på in Leovo tab 4 och VIPS! Det fungerar.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Jag kunde utan problem få ut konfigurationsfilen från en av våra switchar.
Det är en av anledningarna att det är så viktigt med ”Enable” lösenord. (som vi använder oss av)
Man kan spara makron i applikationen så med ett enkelt knapptryck så kan man ladda ner hela konfigurationen.

Active Directory testa standardlösenord

Om ni har ett standardlösenord ni använder när nya konton skapas, använd följande kommando i powershell för att kontrollera att användarna har ändrat det.

Get-ADUser -Filter * -SearchBase ”DC=domain,DC=local” | ForEach {
$_.SamAccountName
(new-object directoryservices.directoryentry ””, (”domain\” + $_.SamAccountName), ”password”).psbase.name -ne $null
Write-Host ””
}

Ändra bara domännamnet till ditt korrekta samt password till standardlösenordet du vill testa.