@@ -648,7 +648,7 @@ Function Uninstall-LTService{
648
648
}
649
649
Foreach ($Svr in $Server ) {
650
650
If (-not ($GoodServer )) {
651
- If ($Svr -match ' ^(https?://)?(([12]?[0-9]{1,2}\.){3}[12]?[0-9]{1,2}|[a-z0-9][a-z0-9_-]* (\.[a-z0-9][a-z0-9_-]*){1,} )$' ) {
651
+ If ($Svr -match ' ^(https?://)?(([12]?[0-9]{1,2}\.){3}[12]?[0-9]{1,2}|[a-z0-9][a-z0-9_-]+ (\.[a-z0-9][a-z0-9_-]*)* )$' ) {
652
652
Try {
653
653
If ($Svr -notmatch ' https?://.+' ) {$Svr = " http://$ ( $Svr ) " }
654
654
$SvrVerCheck = " $ ( $Svr ) /Labtech/Agent.aspx"
@@ -984,14 +984,15 @@ Function Install-LTService{
984
984
985
985
Begin {
986
986
Clear-Variable DotNET, OSVersion, PasswordArg, Result, logpath, logfile, curlog, installer, installerTest, installerResult, GoodServer, GoodTrayPort, TestTrayPort, Svr, SVer, SvrVer, SvrVerCheck, iarg, timeout, sw, tmpLTSI - EA 0 - WhatIf:$False - Confirm:$False # Clearing Variables for use
987
- Write-Debug " Starting $ ( $myInvocation.InvocationName ) "
987
+ Set-Alias - name LINENUM - value Get-CurrentLineNumber - WhatIf:$False - Confirm:$False
988
+ Write-Debug " Starting $ ( $myInvocation.InvocationName ) at line $ ( LINENUM) "
988
989
989
990
If (! ($Force )) {
990
991
If (Get-Service ' LTService' , ' LTSvcMon' - ErrorAction SilentlyContinue) {
991
992
If ($WhatIfPreference -ne $True ) {
992
- Write-Error " Services are already installed." - ErrorAction Stop
993
+ Write-Error " ERROR: Line $ ( LINENUM ) : Services are already installed." - ErrorAction Stop
993
994
} Else {
994
- Write-Error " What if: Stopping: Services are already installed." - ErrorAction Stop
995
+ Write-Error " ERROR: Line $ ( LINENUM ) : What if: Stopping: Services are already installed." - ErrorAction Stop
995
996
}# End If
996
997
}# End If
997
998
}# End If
@@ -1018,7 +1019,7 @@ Function Install-LTService{
1018
1019
}
1019
1020
}
1020
1021
catch {
1021
- Write-Error " ERROR: .NET 3.5 install failed." - ErrorAction Continue
1022
+ Write-Error " ERROR: Line $ ( LINENUM ) : .NET 3.5 install failed." - ErrorAction Continue
1022
1023
if (! ($Force )) { Write-Error $Install - ErrorAction Stop }
1023
1024
}
1024
1025
}
@@ -1032,7 +1033,7 @@ Function Install-LTService{
1032
1033
Write-Warning " .Net Framework 3.5 has been installed and enabled."
1033
1034
}
1034
1035
Else {
1035
- Write-Error " ERROR: .NET 3.5 install failed." - ErrorAction Continue
1036
+ Write-Error " ERROR: Line $ ( LINENUM ) : .NET 3.5 install failed." - ErrorAction Continue
1036
1037
If (! ($Force )) { Write-Error $Result - ErrorAction Stop }
1037
1038
}# End If
1038
1039
}# End If
@@ -1044,12 +1045,12 @@ Function Install-LTService{
1044
1045
If (-not ($DotNet -like ' 3.5.*' )){
1045
1046
If (($Force )) {
1046
1047
If ($DotNet -like ' 2.0.*' ){
1047
- Write-Error " ERROR: .NET 3.5 is not detected and could not be installed." - ErrorAction Continue
1048
+ Write-Error " ERROR: Line $ ( LINENUM ) : .NET 3.5 is not detected and could not be installed." - ErrorAction Continue
1048
1049
} Else {
1049
- Write-Error " ERROR: .NET 2.0 is not detected and could not be installed." - ErrorAction Stop
1050
+ Write-Error " ERROR: Line $ ( LINENUM ) : .NET 2.0 is not detected and could not be installed." - ErrorAction Stop
1050
1051
}# End If
1051
1052
} Else {
1052
- Write-Error " ERROR: .NET 3.5 is not detected and could not be installed." - ErrorAction Stop
1053
+ Write-Error " ERROR: Line $ ( LINENUM ) : .NET 3.5 is not detected and could not be installed." - ErrorAction Stop
1053
1054
}# End If
1054
1055
}# End If
1055
1056
}# End If
@@ -1078,7 +1079,7 @@ Function Install-LTService{
1078
1079
}
1079
1080
Foreach ($Svr in $Server ) {
1080
1081
If (-not ($GoodServer )) {
1081
- If ($Svr -match ' ^(https?://)?(([12]?[0-9]{1,2}\.){3}[12]?[0-9]{1,2}|[a-z0-9][a-z0-9_-]* (\.[a-z0-9][a-z0-9_-]*){1,} )$' ) {
1082
+ If ($Svr -match ' ^(https?://)?(([12]?[0-9]{1,2}\.){3}[12]?[0-9]{1,2}|[a-z0-9][a-z0-9_-]+ (\.[a-z0-9][a-z0-9_-]*)* )$' ) {
1082
1083
If ($Svr -notmatch ' https?://.+' ) {$Svr = " http://$ ( $Svr ) " }
1083
1084
Try {
1084
1085
$SvrVerCheck = " $ ( $Svr ) /Labtech/Agent.aspx"
@@ -1207,7 +1208,7 @@ Function Install-LTService{
1207
1208
$svcRun = (' LTService' ) | Get-Service - EA 0 | Measure-Object | Select-Object - Expand Count
1208
1209
} Until ($InstallAttempt -ge 3 -or $svcRun -eq 1 )
1209
1210
If ($svcRun -eq 0 ) {
1210
- Write-Error " LTService was not installed. Installation failed."
1211
+ Write-Error " ERROR: Line $ ( LINENUM ) : LTService was not installed. Installation failed."
1211
1212
return
1212
1213
}
1213
1214
}# End If
@@ -1255,7 +1256,7 @@ Function Install-LTService{
1255
1256
}# End Try
1256
1257
1257
1258
Catch {
1258
- Write-Error " ERROR: There was an error during the install process. $ ( $Error [0 ]) "
1259
+ Write-Error " ERROR: Line $ ( LINENUM ) : There was an error during the install process. $ ( $Error [0 ]) "
1259
1260
return
1260
1261
}# End Catch
1261
1262
@@ -1265,16 +1266,16 @@ Function Install-LTService{
1265
1266
If (($tmpLTSI | Select-Object - Expand ' ID' - EA 0 ) -gt 1 ) {
1266
1267
Write-Output " LabTech has been installed successfully. Agent ID: $ ( $tmpLTSI | Select-Object - Expand ' ID' - EA 0 ) LocationID: $ ( $tmpLTSI | Select-Object - Expand ' LocationID' - EA 0 ) "
1267
1268
} ElseIf (! ($NoWait )) {
1268
- Write-Error " ERROR: LabTech installation completed but Agent failed to register within expected period." - ErrorAction Continue
1269
+ Write-Error " ERROR: Line $ ( LINENUM ) : LabTech installation completed but Agent failed to register within expected period." - ErrorAction Continue
1269
1270
} Else {
1270
1271
Write-Warning " WARNING: LabTech installation completed but Agent did not yet register." - WarningAction Continue
1271
1272
}# End If
1272
1273
} Else {
1273
1274
If (($Error )) {
1274
- Write-Error " ERROR: There was an error installing LabTech. Check the log, $ ( $env: windir ) \temp\LabTech\LTAgentInstall.log $ ( $Error [0 ]) "
1275
+ Write-Error " ERROR: Line $ ( LINENUM ) : There was an error installing LabTech. Check the log, $ ( $env: windir ) \temp\LabTech\LTAgentInstall.log $ ( $Error [0 ]) "
1275
1276
return
1276
1277
} ElseIf (! ($NoWait )) {
1277
- Write-Error " ERROR: There was an error installing LabTech. Check the log, $ ( $env: windir ) \temp\LabTech\LTAgentInstall.log"
1278
+ Write-Error " ERROR: Line $ ( LINENUM ) : There was an error installing LabTech. Check the log, $ ( $env: windir ) \temp\LabTech\LTAgentInstall.log"
1278
1279
return
1279
1280
} Else {
1280
1281
Write-Warning " WARNING: LabTech installation may not have succeeded." - WarningAction Continue
@@ -1283,9 +1284,9 @@ Function Install-LTService{
1283
1284
}# End If
1284
1285
If (($Rename ) -and $Rename -notmatch ' False' ){ Rename-LTAddRemove - Name $Rename }
1285
1286
} ElseIf ( $WhatIfPreference -ne $True ) {
1286
- Write-Error " ERROR: No valid server was reached to use for the install."
1287
+ Write-Error " ERROR: Line $ ( LINENUM ) : No valid server was reached to use for the install."
1287
1288
}# End If
1288
- Write-Debug " Exiting $ ( $myInvocation.InvocationName ) "
1289
+ Write-Debug " Exiting $ ( $myInvocation.InvocationName ) at line $ ( LINENUM ) "
1289
1290
}# End End
1290
1291
}# End Function Install-LTService
1291
1292
@@ -1547,7 +1548,7 @@ Function Update-LTService{
1547
1548
1548
1549
Foreach ($Svr in $Server ) {
1549
1550
If (-not ($GoodServer )) {
1550
- If ($Svr -match ' ^(https?://)?(([12]?[0-9]{1,2}\.){3}[12]?[0-9]{1,2}|[a-z0-9][a-z0-9_-]* (\.[a-z0-9][a-z0-9_-]*){1,} )$' ) {
1551
+ If ($Svr -match ' ^(https?://)?(([12]?[0-9]{1,2}\.){3}[12]?[0-9]{1,2}|[a-z0-9][a-z0-9_-]+ (\.[a-z0-9][a-z0-9_-]*)* )$' ) {
1551
1552
If ($Svr -notmatch ' https?://.+' ) {$Svr = " http://$ ( $Svr ) " }
1552
1553
Try {
1553
1554
$SvrVerCheck = " $ ( $Svr ) /Labtech/Agent.aspx"
@@ -2238,7 +2239,7 @@ Function Test-LTPorts{
2238
2239
)
2239
2240
2240
2241
$RemoteServer = If ([string ]::IsNullOrEmpty($ComputerName )) {$IPAddress } Else {$ComputerName };
2241
- If ([string ]::IsNullOrEmpty($RemoteServer )) {Write-Error " No ComputerName or IPAddress was provided to test." ; return }
2242
+ If ([string ]::IsNullOrEmpty($RemoteServer )) {Write-Error " ERROR: Line $ ( LINENUM ) : No ComputerName or IPAddress was provided to test." ; return }
2242
2243
2243
2244
$test = New-Object System.Net.Sockets.TcpClient;
2244
2245
Try
@@ -2260,7 +2261,8 @@ Function Test-LTPorts{
2260
2261
}# End Function TestPort
2261
2262
2262
2263
Clear-Variable CleanSvr, svr, proc, processes, port, netstat, line - EA 0 - WhatIf:$False - Confirm:$False # Clearing Variables for use
2263
- Write-Debug " Starting $ ( $myInvocation.InvocationName ) "
2264
+ Set-Alias - name LINENUM - value Get-CurrentLineNumber - WhatIf:$False - Confirm:$False
2265
+ Write-Debug " Starting $ ( $myInvocation.InvocationName ) at line $ ( LINENUM) "
2264
2266
2265
2267
}# End Begin
2266
2268
@@ -2312,7 +2314,7 @@ Function Test-LTPorts{
2312
2314
return
2313
2315
}
2314
2316
2315
- if ($Svr -match ' ^(https?://)?(([12]?[0-9]{1,2}\.){3}[12]?[0-9]{1,2}|[a-z0-9][a-z0-9_-]* (\.[a-z0-9][a-z0-9_-]*){1,} )$' ) {
2317
+ If ($Svr -match ' ^(https?://)?(([12]?[0-9]{1,2}\.){3}[12]?[0-9]{1,2}|[a-z0-9][a-z0-9_-]+ (\.[a-z0-9][a-z0-9_-]*)* )$' ) {
2316
2318
Try {
2317
2319
$CleanSvr = ($Svr -replace ' https?://' , ' ' | ForEach-Object {$_.Trim ()})
2318
2320
Write-Output " Testing connectivity to required TCP ports:"
@@ -2324,9 +2326,9 @@ Function Test-LTPorts{
2324
2326
}# End Try
2325
2327
2326
2328
Catch {
2327
- Write-Error " ERROR: There was an error testing the ports. $ ( $Error [0 ]) " - ErrorAction Stop
2329
+ Write-Error " ERROR: Line $ ( LINENUM ) : There was an error testing the ports. $ ( $Error [0 ]) " - ErrorAction Stop
2328
2330
}# End Catch
2329
- } else {
2331
+ } Else {
2330
2332
Write-Warning " Server address $ ( $Svr ) is not a valid address or is not formatted correctly. Example: https://lt.domain.com"
2331
2333
}# End If
2332
2334
}# End Foreach
@@ -2339,7 +2341,7 @@ Function Test-LTPorts{
2339
2341
}
2340
2342
}
2341
2343
Else {$Error [0 ]}
2342
- Write-Debug " Exiting $ ( $myInvocation.InvocationName ) "
2344
+ Write-Debug " Exiting $ ( $myInvocation.InvocationName ) at line $ ( LINENUM ) "
2343
2345
}# End End
2344
2346
}# End Function Test-LTPorts
2345
2347
@@ -3199,7 +3201,8 @@ Function Set-LTProxy{
3199
3201
3200
3202
Begin {
3201
3203
Clear-Variable LTServiceSettingsChanged, LTSS, LTServiceRestartNeeded, proxyURL, proxyUser, proxyPass, passwd, Svr - EA 0 - WhatIf:$False - Confirm:$False # Clearing Variables for use
3202
- Write-Debug " Starting $ ( $myInvocation.InvocationName ) "
3204
+ Set-Alias - name LINENUM - value Get-CurrentLineNumber - WhatIf:$False - Confirm:$False
3205
+ Write-Debug " Starting $ ( $myInvocation.InvocationName ) at line $ ( LINENUM) "
3203
3206
3204
3207
try {
3205
3208
$LTSS = Get-LTServiceSettings - EA 0 - Verbose:$False - WA 0 - Debug:$False
@@ -3215,11 +3218,11 @@ Function Set-LTProxy{
3215
3218
((($ProxyServerURL ) -or ($ProxyUsername ) -or ($ProxyPassword ) -or ($EncodedProxyUsername ) -or ($EncodedProxyPassword )) -and (($ResetProxy -eq $True ) -or ($DetectProxy -eq $True ))) -or
3216
3219
((($ProxyUsername ) -or ($ProxyPassword )) -and (-not ($ProxyServerURL ) -or ($EncodedProxyUsername ) -or ($EncodedProxyPassword ) -or ($ResetProxy -eq $True ) -or ($DetectProxy -eq $True ))) -or
3217
3220
((($EncodedProxyUsername ) -or ($EncodedProxyPassword )) -and (-not ($ProxyServerURL ) -or ($ProxyUsername ) -or ($ProxyPassword ) -or ($ResetProxy -eq $True ) -or ($DetectProxy -eq $True )))
3218
- ) {Write-Error " Set-LTProxy: Invalid Parameter specified" - ErrorAction Stop}
3221
+ ) {Write-Error " ERROR: Line $ ( LINENUM ) : Set-LTProxy: Invalid Parameter specified" - ErrorAction Stop}
3219
3222
If (-not (($ResetProxy -eq $True ) -or ($DetectProxy -eq $True ) -or ($ProxyServerURL ) -or ($ProxyUsername ) -or ($ProxyPassword ) -or ($EncodedProxyUsername ) -or ($EncodedProxyPassword )))
3220
3223
{
3221
- If ($Args.Count -gt 0 ) {Write-Error " Set-LTProxy: Unknown Parameter specified" - ErrorAction Stop}
3222
- Else {Write-Error " Set-LTProxy: Required Parameters Missing" - ErrorAction Stop}
3224
+ If ($Args.Count -gt 0 ) {Write-Error " ERROR: Line $ ( LINENUM ) : Set-LTProxy: Unknown Parameter specified" - ErrorAction Stop}
3225
+ Else {Write-Error " ERROR: Line $ ( LINENUM ) : Set-LTProxy: Required Parameters Missing" - ErrorAction Stop}
3223
3226
}
3224
3227
3225
3228
Try {
@@ -3242,7 +3245,7 @@ Function Set-LTProxy{
3242
3245
$Servers = @ ($ (" $ ( $LTSS | Select-Object - Expand ' ServerAddress' - EA 0 ) |www.connectwise.com" ).Split(' |' )| ForEach-Object {$_.Trim ()})
3243
3246
Foreach ($Svr In $Servers ) {
3244
3247
If (-not ($Script :LTProxy.Enabled )) {
3245
- If ($Svr -match ' ^(https?://)?(([12]?[0-9]{1,2}\.){3}[12]?[0-9]{1,2}|[a-z0-9][a-z0-9_-]* (\.[a-z0-9][a-z0-9_-]*){1,} )$' ) {
3248
+ If ($Svr -match ' ^(https?://)?(([12]?[0-9]{1,2}\.){3}[12]?[0-9]{1,2}|[a-z0-9][a-z0-9_-]+ (\.[a-z0-9][a-z0-9_-]*)* )$' ) {
3246
3249
$Svr = $Svr -replace ' https?://' , ' '
3247
3250
Try {
3248
3251
$Script :LTProxy.ProxyServerURL = $Script :LTWebProxy.GetProxy (" http://$ ( $Svr ) " ).Authority
@@ -3309,7 +3312,7 @@ Function Set-LTProxy{
3309
3312
}# End Try
3310
3313
3311
3314
Catch {
3312
- Write-Error " ERROR: There was an error during the Proxy Configuration process. $ ( $Error [0 ]) " - ErrorAction Stop
3315
+ Write-Error " ERROR: Line $ ( LINENUM ) : There was an error during the Proxy Configuration process. $ ( $Error [0 ]) " - ErrorAction Stop
3313
3316
}# End Catch
3314
3317
}# End Process
3315
3318
@@ -3360,7 +3363,7 @@ Function Set-LTProxy{
3360
3363
}# End If
3361
3364
}# End If
3362
3365
Else {$Error [0 ]}
3363
- Write-Debug " Exiting $ ( $myInvocation.InvocationName ) "
3366
+ Write-Debug " Exiting $ ( $myInvocation.InvocationName ) at line $ ( LINENUM ) "
3364
3367
}# End End
3365
3368
3366
3369
}# End Function Set-LTProxy
0 commit comments