Functions/Profile/Start-ProfileEnvironment.ps1
<# .SYNOPSIS Start the profile environment for the current user. .DESCRIPTION Start the profile environment for the current user. It will perform the following steps: - Verify the last Install-ProfileEnvironment execution - Load encrypted credentials - Load encrypted secure strings - Dot-source the profile.ps1 script .INPUTS None. .OUTPUTS None. .EXAMPLE Start-ProfileEnvironment Start the profile environment with a default path. .NOTES Author : Claudio Spizzi License : MIT License .LINK https://github.com/claudiospizzi/Spizzi.Profile #> function Start-ProfileEnvironment { [CmdletBinding()] param ( [Parameter(Mandatory = $false, Position = 0)] [ValidateScript({ $_ | Join-Path -ChildPath 'profile.xml' | Test-Path })] [System.String] $Path = (Get-ProfileEnvironmentPath) ) # Check if the current executed profile does match the latest version. if ((Import-Clixml "$Path\profile.xml") -ne (Get-Module -Name 'Spizzi.Profile').Version) { Write-Warning 'Your profile environment is not up to date. Please run Install-ProfileEnvironment again.' } # Import all *.credential.xml files and store the PSCredential objects # inside $CRED_<Domain>_<Username> global variables Import-ProfileEnvironmentCredential -Path $Path # Import all *.secret.xml files and store the SecureString objects # inside $SEC_<Domain>_<Username> global variables Import-ProfileEnvironmentSecureString -Path $Path # Dot source the script file . "$Path\profile.ps1" } |