62
62
$ErrorActionPreference = " Stop"
63
63
# Requires -Modules Az .Accounts ,Az .Resources ,Az .Network
64
64
Set-Item Env:\SuppressAzurePowerShellBreakingChangeWarnings " true" | Out-Null
65
+ [string ]$ResourcePath = ($PWD.ProviderPath , $PSScriptRoot )[[bool ]$PSScriptRoot ]
65
66
66
67
# region Grab Configurations
67
68
If ($PSScriptRoot.ToString ().length -eq 0 )
@@ -71,14 +72,14 @@ If($PSScriptRoot.ToString().length -eq 0)
71
72
Break
72
73
}
73
74
Else {
74
- Write-Host (" Loading {0}..." -f " $PSScriptRoot \$ConfigurationFile " ) - ForegroundColor Yellow - NoNewline
75
- . " $PSScriptRoot \$ConfigurationFile " - NoVyosISOCheck
75
+ Write-Host (" Loading {0}..." -f " $ResourcePath \$ConfigurationFile " ) - ForegroundColor Yellow - NoNewline
76
+ . " $ResourcePath \$ConfigurationFile " - NoVyosISOCheck
76
77
}
77
78
# endregion
78
79
79
80
# region start transcript
80
81
$LogfileName = " $RegionBName -AdvSetup-$ ( Get-Date - Format ' yyyy-MM-dd_Thh-mm-ss-tt' ) .log"
81
- Try {Start-transcript " $PSScriptRoot \Logs\$LogfileName " - ErrorAction Stop}catch {Start-Transcript " $PSScriptRoot \$LogfileName " }
82
+ Try {Start-transcript " $ResourcePath \Logs\$LogfileName " - ErrorAction Stop}catch {Start-Transcript " $ResourcePath \$LogfileName " }
82
83
# endregion
83
84
84
85
# Make it a global variable so it used for the entire session
@@ -667,8 +668,8 @@ run show ipsec vpn sa
667
668
668
669
# Always output script
669
670
$ScriptName = $LogfileName.replace (' .log' , ' .script' )
670
- Remove-Item " $PSScriptRoot \Logs\$ScriptName " - Force - ErrorAction SilentlyContinue | Out-Null
671
- $VyOSFinal | Add-Content " $PSScriptRoot \Logs\$ScriptName "
671
+ Remove-Item " $ResourcePath \Logs\$ScriptName " - Force - ErrorAction SilentlyContinue | Out-Null
672
+ $VyOSFinal | Add-Content " $ResourcePath \Logs\$ScriptName "
672
673
$VyOSConfig [' ResetVPNConfigs' ] = $False
673
674
674
675
If ($RouterAutomationMode )
@@ -803,7 +804,7 @@ If($RunManualSteps){
803
804
Write-Host " `n Open ssh session for $ ( $VyOSConfig.VMName ) by running command [" - ForegroundColor White - NoNewline
804
805
Write-Host (" ssh vyos@{0}" -f $VyOSExternalIP ) - ForegroundColor Yellow - NoNewline
805
806
Write-Host " ]" - ForegroundColor White
806
- Write-Host " Then copy the script between the lines or `n from $PSScriptRoot \Logs\$ScriptName " - ForegroundColor White
807
+ Write-Host " Then copy the script between the lines or `n from $ResourcePath \Logs\$ScriptName " - ForegroundColor White
807
808
Write-Host " `n A reboot may be required on $ ( $VyOSConfig.VMName ) for updates to take effect" - ForegroundColor Red
808
809
Write-Host " In router's ssh session, run command [" - ForegroundColor Gray - NoNewline
809
810
Write-Host " reboot now" - ForegroundColor Yellow - NoNewline
0 commit comments