Fortytwo.IAM.ActiveDirectory.UserProvisioning.psm1
|
# Inspiration: https://github.com/RamblingCookieMonster/PSStackExchange/blob/master/PSStackExchange/PSStackExchange.psm1 # To be able to override default server and credential parameters in cmdlets like Get-ADUser, we need to # preserve the global PSDefaultParameterValues and re-apply them to the script scope. $script:PSDefaultParameterValues = $global:PSDefaultParameterValues New-Variable -Scope Script -Name AccessTokenProfile -Value "default" New-Variable -Scope Script -Name SamAccountNameGenerationPatterns -Value @( "{givenName:3}{sn:3}" "{givenName:1}{sn:19}" "{givenName:19}{sn:1}" "{givenName:3}{sn:4}" "{givenName:3}{sn:5}" "{givenName:1}{sn:5}" "{givenName:4}{sn:3}" "{givenName:4}{sn:4}" "{givenName:4}{sn:5}" "{givenName:5}{sn:3}" "{givenName:5}{sn:4}" "{givenName:5}{sn:5}" "{givenName:2}{sn:6}" "{givenName:3}{sn:3}2" "{givenName:3}{sn:4}2" "{givenName:3}{sn:5}2" "{givenName:4}{sn:3}2" "{givenName:4}{sn:4}2" "{givenName:4}{sn:5}2" "{givenName:5}{sn:3}2" "{givenName:5}{sn:4}2" "{givenName:5}{sn:5}2" "{givenName:2}{sn:6}2" ) # Get public and private function definition files. $Private = (Test-Path $PSScriptRoot\Private) ? @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue ) : @() $Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue -Exclude "*.tests.*" ) # Dot source the files in order to define all cmdlets Foreach ($import in @($Public + $Private)) { Try { . $import.fullname } Catch { Write-Error -Message "Failed to import function $($import.fullname): $_" } } # Export all functions Export-ModuleMember -Function $Public.Basename |