Skip to content

Instantly share code, notes, and snippets.

View davegreen's full-sized avatar

Dave Green davegreen

View GitHub Profile
Function TestMsolConnection {
<#
.Synopsis
A function that tests the Microsoft Online connection.
.Description
A function that tests the Microsoft Online connection.
.Example
TestMsolConnection
Register-ArgumentCompleter -CommandName Set-MsolUser -ParameterName UsageLocation -ScriptBlock {
Param(
$commandName, #The command calling this argument completer.
$parameterName, #The parameter currently active for the argument completer.
$currentContent, #The current data in the prompt for the parameter specified above.
$commandAst, #The full AST for the current command.
$fakeBoundParameters #A hashtable of the current parameters on the prompt.
)
$UsageLocations = @{
# Requires -RunAsAdministrator
[CmdletBinding(
SupportsShouldProcess = $True,
ConfirmImpact = 'High'
)]
Param(
[parameter(
Mandatory = $true
)]
[ValidateScript({
@davegreen
davegreen / UpdateBIOS.cmd
Created September 8, 2016 19:38
For use with HP machines for deploying updated UEFI firmware using HPqflash.
PUSHD %~dp0
SET _upd=hpqFlash.exe
SET bios=%1
IF /I "%PROCESSOR_ARCHITECTURE%" EQU "AMD64" (
SET _upd=hpqFlash64.exe
)
"%_upd%" -pBIOSPW.bin -f%bios% -s
@davegreen
davegreen / UpdateUEFI.cmd
Created September 8, 2016 19:34
For use with HP machines for deploying updated UEFI firmware.
PUSHD %~dp0
SET _upd=HPBIOSUPDREC.exe
SET bios=%1
IF /I "%PROCESSOR_ARCHITECTURE%" EQU "AMD64" (
SET _upd=HPBIOSUPDREC64.exe
)
"%_upd%" -pBIOSPW.bin -f%bios% -s -r
@davegreen
davegreen / ConfigureUEFI.cmd
Last active September 8, 2016 19:33
For use with HP machines for deploying UEFI/BIOS configurations.
PUSHD %~dp0
SET _bcu=BiosConfigUtility.exe
SET config=%1
IF /I "%PROCESSOR_ARCHITECTURE%" EQU "AMD64" (
SET _bcu=BiosConfigUtility64.exe
)
"%_bcu%" /nspwdfile:"%~dp0BIOSPW.bin" /set:"%~dp0%config%" /l
#Requires -Module DHCPServer
Function Get-UnmatchedDhcpServerv4Reservation {
<#
.Synopsis
A function gets DHCP IPv4 reservations from a single scope stretched over two DHCP servers.
.Description
A function gets DHCP IPv4 reservations from a single scope stretched over two DHCP servers
@davegreen
davegreen / Set-IdentityManagementGalAdPermission.ps1
Last active October 1, 2021 09:07
This function sets the AD permissions required for MIM to perform GALSync operations. It does this by adding the required new permissions for the GALSync group to AD.
Function Set-IdentityManagementGalAdPermission {
<#
.Synopsis
A function that sets the permissions in Active Directory (AD) required for Microsoft Identity Manager (MIM) to perform Global Address List (GAL) sync operations.
.Description
This function sets the AD permissions required for MIM to perform GALSync operations. It does this by adding the required new permissions for the GALSync group to at least three places in the AD.
The GALSync group requires permissions to AD for the following:
@davegreen
davegreen / Connect-Services.ps1
Last active April 12, 2018 13:01
Functions for connecting to and importing PowerShell sessions for Lync, Exchange (online and on-premise).
Function Test-MsolConnection {
<#
.Synopsis
A function that tests the Microsoft Online connection.
.Example
Test-MsolConnection
Tests to see if the Microsoft Online connection is available.
@davegreen
davegreen / Build-CustomWIMImage.ps1
Created February 1, 2016 21:48
This function mounts and customises a given WIM image by removing pre-provisioned Appx packages and slipstreaming updates. Defaults provided for Appx package removal are based around Windows 10.
Function Build-CustomWIMImage
{
[CmdletBinding(SupportsShouldProcess)]
Param(
[parameter(Mandatory=$true, Position=1)][ValidateScript({ Test-Path $_ })][string]$ImagePath,
[parameter()][ValidateScript({ Test-Path $_ })][string]$UpdatesPath,
[parameter()][ValidateNotNullOrEmpty()][string[]]$RemoveAppxPackages = {
'Microsoft.3DBuilder',
'Microsoft.BingFinance',
'Microsoft.BingNews',