Office 365 Users Photo – Set/Update/Remove

With Office365 you can have profile pictures, and this setting is enabled by default. In larger organizations you may not want this policy enabled or have a customized policy for different departments. Here’s what I had to do to disable the picture upload capability by default and use powershell to update it for individuals by using a customized policy.

Continue reading “Office 365 Users Photo – Set/Update/Remove”

PowerShell Code Snippet

Strip-Word

 Function Strip-Word { 
    Param ( 
        [Parameter(mandatory=$true,Position=1)][string]$word, 
        [Parameter(mandatory=$true,Position=2)][int]$length, 
        [Parameter(mandatory=$false,Position=3)][AllowNull()][switch]$encode 
    )
    
    $word = $word -replace '[^a-zA-Z0-9-\(\)_ ]', ''

    if($encode) { 
        return [System.Web.HttpUtility]::UrlEncode($word.PadRight($length,' ').Substring(0,$length).Trim());
    } else { 
        return $word.PadRight($length,' ').Substring(0,$length).Trim(); 
    }
} 

Continue reading “PowerShell Code Snippet”

Test-ADCredential

# Test-ADCredential.ps1
CLS
<#
.Synopsis
Verify Active Directory credentials

.DESCRIPTION
This function takes a user name and a password as input and will verify if the combination is correct. The function returns a boolean based on the result.

.NOTES   
Name: Test-ADCredential
Author: Jaap Brasser
Version: 1.0
DateUpdated: 2013-05-10

.PARAMETER UserName
The samaccountname of the Active Directory user account
	
.PARAMETER Password
The password of the Active Directory user account

.EXAMPLE
Test-ADCredential -username jaapbrasser -password Secret01

Description:
Verifies if the username and password provided are correct, returning either true or false based on the result
#>
function Test-ADCredential {
    [CmdletBinding()]
    Param
    (
        [string]$UserName,
        [string]$Password
    )
    if (!($UserName) -or !($Password)) {
        Write-Warning 'Test-ADCredential: Please specify both user name and password'
    } else {
        Add-Type -AssemblyName System.DirectoryServices.AccountManagement
        $DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('domain')
        $DS.ValidateCredentials($UserName, $Password)
    }
}

try{ $testADCredential = $null; $testADCredential = Get-Credential } catch { $testADCredential = $null;  }
if($testADCredential -ne $null) { Test-ADCredential -UserName "$($testADCredential.UserName)" -Password "$($testADCredential.GetNetworkCredential().password)"; }

pause; return;