<# FPS:Metadata:Profile:ACTIVE #>

 

<#

 

.SYNOPSIS

    Profile

 

    This assigns the profile to use in assigning $env:PSModulePath. 

 

    Profile Path for all of the powershell users: $PROFILE.AllUsersAllHosts (C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1)

 

    To copy over from the runtime location:

   

        copy C:\FPS\Metadata\profile.ps1 C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1

        -or-

        copy D:\FPS\Metadata\profile.ps1 C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1

 

 

    To copy over from the oneDrive cloud container location:

 

        copy C:\Users\[UserId]\OneDrive\FPS\MetaData\profile.ps1 C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1

 

 

.Notes

This shows how to set the execution policy for the local computer.

 

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Get-ExecutionPolicy -List

 

Scope ExecutionPolicy

        ----- ---------------

MachinePolicy       Undefined

   UserPolicy       Undefined

      Process       Undefined

  CurrentUser    RemoteSigned

 LocalMachine    RemoteSigned

  

The Set-ExecutionPolicy cmdlet uses the ExecutionPolicy parameter to specify the RemoteSigned policy. The Scope parameter specifies the

default scope value, LocalMachine. To view the execution policy settings, use the Get-ExecutionPolicy cmdlet with the List parameter.

 

#>

 

function ConvertTo-DotFill ([int] $pDots, [string] $pStr) {

 

<# .EXAMPLE

$newVal=(ConvertTo-DotFill 40 'Dot Fill This')

#>

    $strNew = ($pStr -as [string])+' '

    while ($strNew.length -lt ($pDots-1)) { $strNew += '.' }

    ($strNew+' ')

}

 

$global:ShowDotLen = 60

  $global:sProShowBuff = (ConvertTo-DotFill $global:ShowDotLen '$global:ShowDotLen')+$global:ShowDotLen+'|'

$global:SCDotLen = 25

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:SCDotLen')+$global:SCDotLen+'|'

$YYYY = Get-Date -UFormat %Y

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$YYYY')+$YYYY+'|'      

$YY = [string]$YYYY.Substring(2,2)

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$YY')+$YY+'|'

$MM = Get-Date -UFormat %m

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$MM')+$MM+'|'

$DD = Get-Date -UFormat %d

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$DD')+$DD+'|'      

 

$global:pro_CurrentUser=$env:USERNAME

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CurrentUser')+$global:pro_CurrentUser+'|'

$global:pro_CI = $env:COMPUTERNAME

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI')+$global:pro_CI+'|'

 

             

# Since Core servers drive the entire CI farm, add them as a configuration (more or less) then let other MetaData files add

# the attributes along with each of the other types of CIs. This allows an extensible way of adding other CI configuration

# types as needed in the future.

 

# NOTE: The source drive MUST be available to all CIs within the domain at all times.

 

$global:pro_Domains = @(

    [PSCustomObject]@{ DomainAlias = "DMN01"; Domain = "GolfPunk";   CoreCI = "DESKTOP-A9GTPL1"; Source = "C:\Users\"+$global:pro_CurrentUser+"\OneDrive"; }

    [PSCustomObject]@{ DomainAlias = "DMN02"; Domain = "BigSky";     CoreCI = "JHDSVR";          Source = "C:\Users\"+$global:pro_CurrentUser+"\OneDrive"; }

#   [PSCustomObject]@{ DomainAlias = "DMN03"; Domain = "[domain]";   CoreCI = "[ci]";            Source = "[source path]"; }

)

 

# Load only the domain CI's applicable for this domain as dictated within the source directory.  All CI's can be

# present here, or just the domain CI's. This depends on the security level necessary for the domain.

foreach ($SrcDomain in $global:pro_Domains) {

    if (Test-Path ($SrcDomain.Source+"\FPS\MetaData\Pro-CIs-"+$SrcDomain.DomainAlias+".ps1")) {

        . ($SrcDomain.Source+"\FPS\MetaData\Pro-CIs-"+$SrcDomain.DomainAlias+".ps1")

    }

}

 

# Augment $global:pro_CI with its attributes.

 

<#           

       $global:pro_CIAttributes.CIID ................. The unique numerical ID given to the CI. Once the profile completes, only this variable or

                                                       $global:pro_CIBase.CI and $global:pro_CIBase.CITemplate should be used within all other

                                                       CmdLets or Snippets to reference the VM/Server/Client.           

       $global:pro_CIAttributes.CI ................... The unique device name given to the physical CI VM or client.  Once the profile completes,

                                                       only this variable or $global:pro_CIBase.CIID and $global:pro_CIBase.CITemplate should be 

                                                       used within all other CmdLets or Snippets to reference the VM/Server/Client.

       $global:pro_CIAttributes.CITemplate ........... The template used to construct all associative MID servers, etc., for the CI. Once the profile

                                                       completes, only this variable or $global:pro_CIBase.CIID and $global:pro_CIBase.CI

                                                       should be used within all other CmdLets or Snippets to reference the VM/Server/Client.

       $global:pro_CIAttributes.RuntimeDrive ......... The current CI machine FPS runtime drive (typically D:)

       $global:pro_CIAttributes.Type ................. The orientation of the CI specific FPS community of CIs. Currently these are "Core",

                                                       "Server" and "Solo".  Other variations of Solo can exist, but only one "Core" and one

                                                       "Server" CI can exist for one region.  Use "Server" for the storage facility/MID Server/CICD

                                                       go-to, "Core" for where the source and any “Make” executions stem from, and "Solo" for all

                                                       that use FPS in runtime mode.

       $global:pro_CIAttributes.Domain ............... The domain where the CI physically exists. Under most cases there will only be one domain

                                                       where all of the FPS CIs exist, but in enterprise situations many domains can be in play. 

                                                       $global:pro_DefaultDomain is a simple variable containing the default domain that is

                                                       typically used in multi-domain situations.

       $global:pro_CIAttributes.SvcAcct .............. The service account to use when remotely connecting to the FPS instance via the UI.

       $global:pro_CIAttributes.Family ............... The family name of the FPS set of code used by the CI.

       $global:pro_CIAttributes.Patch ................ The FPS patch level currently used by the CI.

       $global:pro_CIAttributes.CanConnectToSource ... If a Make is required for a remote VM or Server, the FPS Make actions on the Core server for the

                                                       remote VM or Server will be sent and installed on the device.  Depricated.  All can connect.

       $global:pro_CIAttributes.SourceDrive .......... Pre formatted root for where the source drive exists for the device.

       $global:pro_CIAttributes.SQLDB ................ Name of the Wordpress SQL DB

       $global:pro_CIAttributes.SQLUID ............... UserID to use when accessing the Wordpress SQL DB

       $global:pro_CIAttributes.SQLPort .............. Port to use when accessing the Wordpress SQL DB

       $global:pro_CIAttributes.LocalOpsSite ......... Name of the "local" site resident on the CI

       $global:pro_CIAttributes.GUID ................. Unique GUID for the CI

 

#>

 

$global:pro_CI = $global:pro_CIAttributes | Where {$_.CI -eq $global:pro_CI}

 

$global:pro_Release = $global:pro_CI.Family+'-'+$global:pro_CI.Patch # Depricated. CI's can be running different families and versions

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_Release')+$global:pro_Release+'|'      

$global:pro_DefaultDomain = $global:pro_CI.Domain

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_DefaultDomain')+$global:pro_DefaultDomain+'|'

 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.CIID')+$global:pro_CI.CIID+'|'      

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.CI')+$global:pro_CI.CI+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.CITemplate')+$global:pro_CI.CITemplate+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.RuntimeDrive')+$global:pro_CI.RuntimeDrive+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.Type')+$global:pro_CI.Type+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.Domain')+$global:pro_CI.Domain+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.SvcAcct')+$global:pro_CI.SvcAcct+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.Family')+$global:pro_CI.Family+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.Patch')+$global:pro_CI.Patch+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.CanConnectToSource')+$global:pro_CI.CanConnectToSource+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.SourceDrive')+$global:pro_CI.SourceDrive+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.SQLDB')+$global:pro_CI.SQLDB+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.SQLUID')+$global:pro_CI.SQLUID+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.SQLPort')+$global:pro_CI.SQLPort+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.LocalOpsSite')+$global:pro_CI.LocalOpsSite+'|'

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CI.GUID')+$global:pro_CI.GUID+'|'

 

# NOTE: Never change $global:pro_CI in the code.  If adjustments are necessary, $global:pro_CIBase is the dynamic set of attributes.

 

# Base CI Locational information.  These are built upon in the locations.ps1 call

$global:pro_CIBase = @(

    [PSCustomObject]@{ 

                        CIID = $global:pro_CI.CIID;

                        CI = $global:pro_CI.CI;

                        CITemplate = $global:pro_CI.CITemplate;

 

                        RuntimeFamily = $global:pro_CI.Family;

                        RuntimePatch = $global:pro_CI.Patch;

                        RuntimeRoot = $global:pro_CI.RuntimeDrive+"\FPS";

                        RuntimeCollections =  $global:pro_CI.RuntimeDrive+"\FPS\Collections";

                        RuntimeContainer = $global:pro_CI.RuntimeDrive+"\FPS\Containers";

                        RuntimeMedia =  $global:pro_CI.RuntimeDrive+"\FPS\Media";

                        RuntimeMetadata =  $global:pro_CI.RuntimeDrive+"\FPS\MetaData";

                        RuntimeScratch =  $global:pro_CI.RuntimeDrive+"\FPS\Media\Scratch";

                        RuntimeLogs =  $global:pro_CI.RuntimeDrive+"\FPS\Media\Logs";

                        RuntimeWeb = $global:pro_CI.RuntimeDrive+"\FPS\Media\Web";

                                                                                         

                        }

)

 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CIBase.CIID')+$global:pro_CIBase.CIID+'|' 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CIBase.CI')+$global:pro_CIBase.CI+'|' 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CIBase.CITemplate')+$global:pro_CIBase.CITemplate+'|' 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CIBase.RuntimeFamily')+$global:pro_CIBase.RuntimeFamily+'|' 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CIBase.RuntimePatch')+$global:pro_CIBase.RuntimePatch+'|' 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CIBase.RuntimeRoot')+$global:pro_CIBase.RuntimeRoot+'|' 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CIBase.RuntimeCollections')+$global:pro_CIBase.RuntimeCollections+'|' 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CIBase.RuntimeContainer')+$global:pro_CIBase.RuntimeContainer+'|' 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CIBase.RuntimeMedia')+$global:pro_CIBase.RuntimeMedia+'|' 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CIBase.RuntimeMetadata')+$global:pro_CIBase.RuntimeMetadata+'|' 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CIBase.RuntimeScratch')+$global:pro_CIBase.RuntimeScratch+'|' 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CIBase.RuntimeLogs')+$global:pro_CIBase.RuntimeLogs+'|' 

  $global:sProShowBuff += (ConvertTo-DotFill $global:ShowDotLen '$global:pro_CIBase.RuntimeWeb')+$global:pro_CIBase.RuntimeWeb+'|'

 

<# Dependencies drive the load/unload of most modules. Modules are not loaded to increase startup times mainly to replicate the load time

   of a typical Servicenow action. Uncomment if traditional module loads are what should be used in the future.

 

# Check $Env:PSModulePath

$global:pro_PSModulePath = [Environment]::GetEnvironmentVariable("PSModulePath")

if ($global:pro_PSModulePath.indexof($global:pro_CIBase.Runtime) -eq -1) {

    $global:pro_PSModulePath += ";"+$global:pro_CIBase.Runtime

    [Environment]::SetEnvironmentVariable("PSModulePath",$global:pro_PSModulePath)

}

 

#>

 

# Configures all of the locations.  No location callouts should exist in the code, all locations will be within this file for all instances of FPS.

. ($global:pro_CIBase.RuntimeMetadata+"\Pro-Locations.ps1")

 

# Configure all of the FPS data encapsulations, snippets, shortcuts, etc.

. ($global:pro_CIBase.RuntimeMetadata+"\Pro-Config.ps1")

 

# This is only intended to be used on an interactive device.

$console = (Get-Host).UI.RawUI

$buffer = $console.BufferSize

$buffer.Width = 360

$buffer.Height = 3000

$console.BufferSize = $buffer