GitClone fix
GitClone will work even when Scripts dir already exist
This commit is contained in:
parent
607fff132f
commit
7117e78a7a
|
@ -25,38 +25,49 @@ function _Setup {
|
|||
## ProfileCode function (source) will contain the code to be written
|
||||
#######################################################################
|
||||
function ProfileCode_pre_common {
|
||||
# # If TMUX isn't loaded, start byobu, then exit this script (and current shell)
|
||||
# if ( -not ( Test-Path env:TMUX ) ) { byobu; exit }
|
||||
# # If TMUX isn't loaded, start byobu, then exit this script (and current shell)
|
||||
# if ( -not ( Test-Path env:TMUX ) ) { byobu; exit }
|
||||
}
|
||||
#######################################################################
|
||||
## common Profile Code - receommended not to change this
|
||||
## Code will be loaded from profile.d sub-directory after this.
|
||||
#######################################################################
|
||||
function ProfileCode_post_common {
|
||||
# This loads the personal profile section from the $MyPSScriptRoot/profile.d directory
|
||||
Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { . $_.Name }
|
||||
# This loads the personal profile section from the $MyPSScriptRoot/profile.d directory
|
||||
Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { . $_.Name }
|
||||
}
|
||||
#######################################################################
|
||||
## Setup-Profile code continues below
|
||||
#######################################################################
|
||||
|
||||
if ( $GitClone -and -not (Test-Path $(Join-Path $MyPSScriptRoot '.git')) ) {
|
||||
if( -not [bool]$(Get-Command git -ErrorAction SilentlyContinue) ) {
|
||||
if ( -not [bool]$(Get-Command git -ErrorAction SilentlyContinue) ) {
|
||||
throw "No git command found, you may either omit the -GitClone switch or install git and try again."
|
||||
}
|
||||
if( $PSCmdlet.ShouldProcess("Pull git repo from $GitURL into $MyPSScriptRoot ?") ) {
|
||||
git clone $GitURL $MyPSScriptRoot
|
||||
if ( $PSCmdlet.ShouldProcess("Pull git repo from $GitURL into $MyPSScriptRoot ?") ) {
|
||||
Push-Location $MyPSScriptRoot
|
||||
$local:tmpGitDir = New-TemporaryFile
|
||||
Remove-Item $tmpGitDir
|
||||
New-Item -Type Directory $tmpGitDir.FullName | Out-Null
|
||||
$local:GitOutput = "$(& git clone $GitURL $tmpGitDir.FullName --no-checkout)"
|
||||
Write-Verbose $GitOutput
|
||||
Move-Item (Join-Path $tmpGitDir.FullName .git) ./.git
|
||||
Remove-Item $tmpGitDir.FullName
|
||||
$GitOutput = "$(& git checkout --force)"
|
||||
Write-Verbose $GitOutput
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
|
||||
$local:ProfileSignature = [PSCustomObject]([ordered]@{
|
||||
Begin = '#### SZ Auto Profile Setup - BEGIN ####'
|
||||
End = '#### SZ Auto Profile Setup - END ####'
|
||||
})
|
||||
Removed = '#### SZ Auto Profile Setup'
|
||||
})
|
||||
|
||||
function New-ProfileSetupStatus{
|
||||
param($Name,$Path,$Status,$Exist)
|
||||
return [PSCustomObject]([ordered]@{
|
||||
function New-ProfileSetupStatus {
|
||||
param($Name, $Path, $Status, $Exist)
|
||||
return [PSCustomObject]([ordered]@{
|
||||
Name = $Name
|
||||
Path = $Path
|
||||
Status = $Status
|
||||
|
@ -64,21 +75,21 @@ param($Name,$Path,$Status,$Exist)
|
|||
})
|
||||
}
|
||||
|
||||
$local:_profiles= $PROFILE | fl * -Force | Out-String -Stream | ForEach-Object {
|
||||
$local:_profiles = $PROFILE | fl * -Force | Out-String -Stream | ForEach-Object {
|
||||
$local:p = $($_ -split ' : [/A-Z\\]');
|
||||
if( $p[0] -match 'User' ) {
|
||||
if ( $p[0] -match 'User' ) {
|
||||
$p[0].Trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
$local:_profile = $profile.CurrentUserAllHosts;
|
||||
$local:randomSeed = "####$(Get-Random)####";
|
||||
|
||||
if( $RemoveOnly -and $ConfirmPreference -eq 'High' -and (-not $PSBoundParameters -or -not $PSBoundParameters.ContainsKey('Confirm')) ) {
|
||||
if ( $RemoveOnly -and $ConfirmPreference -eq 'High' -and (-not $PSBoundParameters -or -not $PSBoundParameters.ContainsKey('Confirm')) ) {
|
||||
$script:ConfirmPreference = 'Low'
|
||||
}
|
||||
|
||||
|
||||
if( $sudo -or $(Test-IsAdmin) ) { $_profile = $profile.AllUsersAllHosts }
|
||||
if ( $sudo -or $(Test-IsAdmin) ) { $_profile = $profile.AllUsersAllHosts }
|
||||
$_profiles | Foreach-Object {
|
||||
$local:p = Invoke-Expression "`$profile.$_"
|
||||
$local:profileContent = $randomSeed;
|
||||
|
@ -89,14 +100,15 @@ $_profiles | Foreach-Object {
|
|||
Write-Verbose "Found code in [$_]'$p', preparing..."
|
||||
$local:gate = $true;
|
||||
$profileContent = Get-Content $p | ForEach-Object {
|
||||
if( -not $gate ) {
|
||||
if ( -not $gate ) {
|
||||
if ( $_ -match $ProfileSignature.End ) {
|
||||
$gate = $true;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if ( $_ -match $ProfileSignature.Begin ) {
|
||||
$gate = $false;
|
||||
$cleanupValue = ' '
|
||||
$cleanupValue = $ProfileSignature.Removed
|
||||
return $randomSeed;
|
||||
}
|
||||
return $_
|
||||
|
@ -104,9 +116,11 @@ $_profiles | Foreach-Object {
|
|||
}
|
||||
}
|
||||
|
||||
if( ($p -eq $_profile) -and -not $RemoveOnly ) {
|
||||
$local:insertProfileCode = $false;
|
||||
if ( ($p -eq $_profile) -and -not $RemoveOnly ) {
|
||||
$insertProfileCode = $true
|
||||
Write-Verbose "Inserting ProfileCode into $($_)..."
|
||||
$profileContent = $profileContent -replace $randomSeed,$((@(
|
||||
$cleanupValue = $((@(
|
||||
'',
|
||||
$ProfileSignature.Begin,
|
||||
'',
|
||||
|
@ -119,55 +133,61 @@ $_profiles | Foreach-Object {
|
|||
$(Export-FunctionSource -NoHeader ProfileCode_post_common),
|
||||
'',
|
||||
$ProfileSignature.End
|
||||
) -join "`n" ).Trim().Replace(('$'+'_'),('$$'+'_')))
|
||||
) -join "`n" ).Trim().Replace(('$' + '_'), ('$$' + '_')))
|
||||
}
|
||||
$profileContent = $($profileContent -replace $randomSeed,$cleanupValue).Trim()
|
||||
$profileContent = $($profileContent -replace $randomSeed, $cleanupValue).Trim()
|
||||
|
||||
$local:shouldSudo = $sudo -and -not $userFile
|
||||
$local:status = 'Skipped'
|
||||
if( $VerbosePreference -eq 'Continue' ) { $ShowSkipped = $true }
|
||||
if( -not ([string]::IsNullOrWhiteSpace($profileContent)) ) {
|
||||
$status = "Need $(if($cleanupValue){'Setup'}else{'Cleanup'})"
|
||||
if( $sudo -or $userFile ) {
|
||||
if ( $VerbosePreference -eq 'Continue' ) { $ShowSkipped = $true }
|
||||
if ( -not ([string]::IsNullOrWhiteSpace($profileContent)) ) {
|
||||
$status = "Need $(if($insertProfileCode){'Setup'}else{'Cleanup'})"
|
||||
if ( $sudo -or $userFile ) {
|
||||
Write-Verbose "Writing content to $($_)..."
|
||||
$local:tmpOutput = New-TemporaryFile -WhatIf:$false
|
||||
$profileContent | Out-File $tmpOutput.FullName -WhatIf:$false
|
||||
if( $shouldSudo -and $( $PSVersionTable.Platform -eq 'Unix' ) ) {
|
||||
if ( $shouldSudo -and $( $PSVersionTable.Platform -eq 'Unix' ) ) {
|
||||
Invoke-ExpressionEx -sudo:$shouldSudo chmod 'a+r' $tmpOutput.FullName
|
||||
}
|
||||
try {
|
||||
function BreakPointHere{} BreakPointHere;
|
||||
function BreakPointHere {} BreakPointHere;
|
||||
|
||||
$local:errMsg = $(Invoke-ExpressionEx -sudo:$shouldSudo "Move-Item $($tmpOutput.FullName) $p -Force:`$$Force -ErrorAction Stop | Out-Null" 2>&1)
|
||||
if( $errMsg ) {
|
||||
if ( $errMsg ) {
|
||||
Write-Error "$errMsg"
|
||||
$status = $status -replace 'Need ','Failed '
|
||||
} else {
|
||||
$status = $status -replace 'Need ',''
|
||||
$status = $status -replace 'Need ', 'Failed '
|
||||
}
|
||||
} catch {
|
||||
else {
|
||||
$status = $status -replace 'Need ', ''
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Error "Writing $p failed!"
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$status = "Need $status"
|
||||
Write-Error "Cannot write into [$_]'$p'! Please re-run with sudo."
|
||||
}
|
||||
} elseif( ($Force -or $RemoveOnly) -and $exists ) {
|
||||
}
|
||||
elseif ( ($Force -or $RemoveOnly) -and $exists ) {
|
||||
$status = 'Need Removal'
|
||||
if( $sudo -or $userFile ) {
|
||||
if ( $sudo -or $userFile ) {
|
||||
Write-Verbose "Removing [$_]'$p'..."
|
||||
try {
|
||||
Invoke-ExpressionEx -sudo:$shouldSudo Remove-Item $p
|
||||
if( -not (Test-Path $p) ) { $status = 'Removed' }
|
||||
} catch {
|
||||
if ( -not (Test-Path $p) ) { $status = 'Removed' }
|
||||
}
|
||||
catch {
|
||||
Write-Error "Removal of $p failed!"
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Write-Error "Cannot remove [$_]'$p'! Please re-run with sudo."
|
||||
}
|
||||
}
|
||||
if( $status -ne 'Skipped' -or $ShowSkipped ) {
|
||||
if( $shouldSudo -and $status -ne 'Skipped' ) { $status = "$status via sudo" }
|
||||
if ( $status -ne 'Skipped' -or $ShowSkipped ) {
|
||||
if ( $shouldSudo -and $status -ne 'Skipped' ) { $status = "$status via sudo" }
|
||||
New-ProfileSetupStatus -Name $_ -Path $p -Status $status -Exist $(Test-Path $p)
|
||||
}
|
||||
}
|
||||
|
@ -175,70 +195,76 @@ $_profiles | Foreach-Object {
|
|||
Remove-Item function:ProfileCode* -Confirm:$false
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
## ProfileCode_common (source) containing mandatory code for $PROFILE
|
||||
#######################################################################
|
||||
function ProfileCode_common {
|
||||
function Get-PowerShellPath {
|
||||
Get-Process -PID $PID | ForEach-Object { $_.Path,$_.Parent.Path } | Where-Object { $_ -match 'powershell|pwsh' } | Select-Object -First 1
|
||||
}
|
||||
function Get-PowerShellPath {
|
||||
Get-Process -PID $PID | ForEach-Object { $_.Path, $_.Parent.Path } | Where-Object { $_ -match 'powershell|pwsh' } | Select-Object -First 1
|
||||
}
|
||||
|
||||
function ConvertTo-Base64 {
|
||||
param([string]$String)
|
||||
function ConvertTo-Base64 {
|
||||
param([string]$String)
|
||||
return [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($String))
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-ExpressionEx {
|
||||
[CmdletBinding(SupportsShouldProcess)]param(
|
||||
function Invoke-ExpressionEx {
|
||||
[CmdletBinding(SupportsShouldProcess)]param(
|
||||
[switch]$sudo,
|
||||
[switch]$Force,
|
||||
[string]$Function,
|
||||
[switch]$MarshalOutput,
|
||||
[Parameter(Position = 1, ValueFromRemainingArguments = $true)]
|
||||
[string[]]$expr
|
||||
)
|
||||
)
|
||||
|
||||
function do_sudo {
|
||||
[CmdletBinding()]param (
|
||||
function do_sudo {
|
||||
[CmdletBinding()]param(
|
||||
[string]$sudo_cmd
|
||||
)
|
||||
)
|
||||
|
||||
function do_sudo_win {
|
||||
[CmdletBinding()]param (
|
||||
[CmdletBinding()]param(
|
||||
[string]$sudo_cmd
|
||||
)
|
||||
|
||||
$local:sudo_exec = [string]::Empty
|
||||
if( (Get-Command scoop -ErrorAction SilentlyContinue) ) {
|
||||
if ( (Get-Command scoop -ErrorAction SilentlyContinue) ) {
|
||||
$sudo_exec = $(scoop which gsudo *>&1)
|
||||
if( $sudo_exec -match 'not found' ) {
|
||||
if ( $sudo_exec -match 'not found' ) {
|
||||
$sudo_exec = $(scoop which sudo *>&1)
|
||||
}
|
||||
if( $sudo_exec -match 'not found' ) { $sudo_exec = [string]::Empty }
|
||||
if ( $sudo_exec -match 'not found' ) { $sudo_exec = [string]::Empty }
|
||||
}
|
||||
if( $sudo_exec ) {
|
||||
if ( $sudo_exec ) {
|
||||
& $sudo_exec $sudo_cmd
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Write-Error "Didn't find a known sudo command"
|
||||
}
|
||||
}
|
||||
|
||||
if( $PSVersionTable.Platform -eq 'Unix' ) {
|
||||
if ( $PSVersionTable.Platform -eq 'Unix' ) {
|
||||
/usr/bin/env sudo $(Get-PowerShellPath) "-noprofile" "-EncodedCommand" $(ConvertTo-Base64 $sudo_cmd)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$local:currentIdenity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
if( $currentIdenity.UserClaims.Value -contains 'S-1-5-32-544' ) {
|
||||
if ( $currentIdenity.UserClaims.Value -contains 'S-1-5-32-544' ) {
|
||||
do_sudo_win $sudo_cmd
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Write-Error "User [$($currentIdenity.Name)]does not have permissions to run as admin."
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( $sudo -and -not $(Test-IsAdmin) ) {
|
||||
if ( $sudo -and -not $(Test-IsAdmin) ) {
|
||||
$local:tmpOutputFile = $null
|
||||
$local:tmpScriptFile = $null
|
||||
|
||||
$local:sudo_cmd = "$($expr -join ' ')".Trim()
|
||||
if( $Function ) {
|
||||
if ( $Function ) {
|
||||
$tmpScriptFile = New-TemporaryFile -WhatIf:$false -Confirm:$false
|
||||
$tmpScriptFile = Move-Item $tmpScriptFile.FullName "$($tmpScriptFile.FullName).ps1" -PassThru -WhatIf:$false -Confirm:$false
|
||||
|
||||
|
@ -256,7 +282,7 @@ function ProfileCode_common {
|
|||
"`n`$ConfirmPreference='$ConfirmPreference';`n"
|
||||
) + $expr
|
||||
|
||||
if( $MarshalOutput ) {
|
||||
if ( $MarshalOutput ) {
|
||||
$tmpOutputFile = New-TemporaryFile -WhatIf:$false -Confirm:$false
|
||||
$expr += @( "| Export-CliXml -Path '$($tmpOutputFile.FullName)'" )
|
||||
}
|
||||
|
@ -272,21 +298,21 @@ function ProfileCode_common {
|
|||
## do_sudo 'Get-Content' $tmpScriptFile.FullName '|' 'Invoke-Expression' '|' 'Export-Clixml' '-Path' $tmpOutputFile.FullName
|
||||
#do_sudo $sudo_cmd
|
||||
|
||||
if( $tmpScriptFile ) { Remove-Item $tmpScriptFile }
|
||||
if( $tmpOutputFile ) { Import-Clixml $tmpOutputFile; Remove-Item $tmpOutputFile }
|
||||
if ( $tmpScriptFile ) { Remove-Item $tmpScriptFile }
|
||||
if ( $tmpOutputFile ) { Import-Clixml $tmpOutputFile; Remove-Item $tmpOutputFile }
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Write-Verbose "Perofrming the following expression in-line:`n{$($expr -join ' ')}"
|
||||
Invoke-Expression "$expr"
|
||||
}
|
||||
Write-Verbose "Perofrming the following expression in-line:`n{$($expr -join ' ')}"
|
||||
Invoke-Expression "$expr"
|
||||
}
|
||||
|
||||
function Test-IsAdmin{
|
||||
[CmdletBinding(ConfirmImpact = 'None')]
|
||||
[OutputType([bool])]
|
||||
param ()
|
||||
function Test-IsAdmin {
|
||||
[CmdletBinding(ConfirmImpact = 'None')]
|
||||
[OutputType([bool])]
|
||||
param()
|
||||
|
||||
switch($true){
|
||||
switch ($true) {
|
||||
$( ($PSVersionTable.PSEdition -eq 'Desktop') -or
|
||||
($PSVersionTable.Platform -eq 'Win32NT')
|
||||
) {
|
||||
|
@ -310,74 +336,71 @@ function ProfileCode_common {
|
|||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function Export-FunctionSource {
|
||||
param(
|
||||
function Export-FunctionSource {
|
||||
param(
|
||||
[switch]$NoHeader,
|
||||
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
|
||||
#[ValidateSet([Functions])]
|
||||
[string[]]$FunctionName
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
$local:src = ""
|
||||
foreach( $local:func in $FunctionName ) {
|
||||
if( -not $NoHeader ) { $src += "`nfunction $func {" }
|
||||
$local:src = ""
|
||||
foreach ( $local:func in $FunctionName ) {
|
||||
if ( -not $NoHeader ) { $src += "`nfunction $func {" }
|
||||
$src += "`n"
|
||||
$src += $((Get-Command -Type Function $func).Definition) ### .Replace(('$'+'_'),('$$'+'_'))
|
||||
if( -not $NoHeader ) { $src += "`n}" }
|
||||
if ( -not $NoHeader ) { $src += "`n}" }
|
||||
$src += "`n"
|
||||
}
|
||||
return $src.Trim()
|
||||
}
|
||||
|
||||
# Are we running in Unix or Windows?
|
||||
$global:PathEnvDelimiter = $(if( $PSVersionTable.Platform -match 'unix' ) {':'} else {';'})
|
||||
function Split-PathEnv {
|
||||
param([string]$EnvPath)
|
||||
$EnvPath -split $PathEnvDelimiter
|
||||
}
|
||||
|
||||
# Establish Module Path
|
||||
$global:MyPSModulePath = Split-PathEnv $env:PSModulePath |
|
||||
Where-Object { $_ -match "^$($(Resolve-Path ~) -replace '\\',"\\")" } |
|
||||
Where-Object { Test-Path $_ } |
|
||||
Get-Item | Sort-Object -Property LastWriteTime -Descending |
|
||||
Select-Object -ExpandProperty FullName -First 1
|
||||
|
||||
if( -not $MyPSModulePath ) {
|
||||
$MyPSModulePath = $(Join-Path $(Join-Path $(Resolve-Path ~) 'powershell') 'Modules')
|
||||
$env:PSModulePath = "$MyPSModulePath$PathEnvDelimiter$env:PSModulePath"
|
||||
}
|
||||
if( -not (Test-Path $MyPSModulePath) ) {
|
||||
New-Item -ItemType Directory -Path $MyPSModulePath -Force | Out-Null
|
||||
}
|
||||
|
||||
Write-Verbose $(Get-Item $MyPSModulePath | Select-Object -ExpandProperty FullName)
|
||||
|
||||
# Establish local/personal Script Root and make sure it's in $env:Path
|
||||
$local:p = Split-PathEnv $env:PATH
|
||||
$MyPSScriptRoot = Join-Path (Split-Path -Parent $MyPSModulePath) Scripts
|
||||
Write-Verbose "MyPSScriptRoot = $MyPSScriptRoot"
|
||||
if( -not (Test-Path $MyPSScriptRoot) ) {
|
||||
New-Item -ItemType Directory -Path $MyPSScriptRoot -Force | Out-Null
|
||||
New-Item -ItemType Directory -Path $MyPSScriptRoot/profile.d -Force | Out-Null
|
||||
}
|
||||
$global:MyPSScriptRoot = $MyPSScriptRoot
|
||||
|
||||
$p = @($p[0], $MyPSScriptRoot) + $($p | Select-Object -Skip 1)
|
||||
$env:PATH = $p -join $PathEnvDelimiter
|
||||
}
|
||||
return $src.Trim()
|
||||
}
|
||||
|
||||
# Are we running in Unix or Windows?
|
||||
$global:PathEnvDelimiter = $(if ( $PSVersionTable.Platform -match 'unix' ) { ':' } else { ';' })
|
||||
function Split-PathEnv {
|
||||
param([string]$EnvPath)
|
||||
$EnvPath -split $PathEnvDelimiter
|
||||
}
|
||||
|
||||
if ( -not $MyPSScriptRoot -or (Test-Path function:Test-IsAdmin,function:ConvertTo-Base64,function:Invoke-ExpressionEx,function:Get-PowerShellPath,function:Export-FunctionSource | Where-Object { -not $_ } | Measure-Object | Select-Object -ExpandProperty Count) ) {
|
||||
# Establish Module Path
|
||||
$global:MyPSModulePath = Split-PathEnv $env:PSModulePath |
|
||||
Where-Object { $_ -match "^$($(Resolve-Path ~) -replace '\\',"\\")" } |
|
||||
Where-Object { Test-Path $_ } |
|
||||
Get-Item | Sort-Object -Property LastWriteTime -Descending |
|
||||
Select-Object -ExpandProperty FullName -First 1
|
||||
|
||||
if ( -not $MyPSModulePath ) {
|
||||
$MyPSModulePath = $(Join-Path $(Join-Path $(Resolve-Path ~) 'powershell') 'Modules')
|
||||
$env:PSModulePath = "$MyPSModulePath$PathEnvDelimiter$env:PSModulePath"
|
||||
}
|
||||
if ( -not (Test-Path $MyPSModulePath) ) {
|
||||
New-Item -ItemType Directory -Path $MyPSModulePath -Force | Out-Null
|
||||
}
|
||||
|
||||
Write-Verbose $(Get-Item $MyPSModulePath | Select-Object -ExpandProperty FullName)
|
||||
|
||||
# Establish local/personal Script Root and make sure it's in $env:Path
|
||||
$local:p = Split-PathEnv $env:PATH
|
||||
$MyPSScriptRoot = Join-Path (Split-Path -Parent $MyPSModulePath) Scripts
|
||||
Write-Verbose "MyPSScriptRoot = $MyPSScriptRoot"
|
||||
if ( -not (Test-Path $MyPSScriptRoot) ) {
|
||||
New-Item -ItemType Directory -Path $MyPSScriptRoot -Force | Out-Null
|
||||
New-Item -ItemType Directory -Path $MyPSScriptRoot/profile.d -Force | Out-Null
|
||||
}
|
||||
$global:MyPSScriptRoot = $MyPSScriptRoot
|
||||
|
||||
$p = @($p[0], $MyPSScriptRoot) + $($p | Select-Object -Skip 1)
|
||||
$env:PATH = $p -join $PathEnvDelimiter
|
||||
}
|
||||
|
||||
if ( -not $MyPSScriptRoot -or (Test-Path function:Test-IsAdmin, function:ConvertTo-Base64, function:Invoke-ExpressionEx, function:Get-PowerShellPath, function:Export-FunctionSource | Where-Object { -not $_ } | Measure-Object | Select-Object -ExpandProperty Count) ) {
|
||||
Write-Verbose "Calling ProfileCode inline..."
|
||||
. ProfileCode_common
|
||||
}
|
||||
|
||||
if( -not $SetupFromWeb ) {
|
||||
if ( -not $SetupFromWeb ) {
|
||||
_setup @PSBoundParameters
|
||||
Get-Item function:_setup | Remove-Item
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue