From 617fcb1373d15983656801ac6b6a7b09e8a37adb Mon Sep 17 00:00:00 2001 From: Ken Ward Date: Fri, 1 Dec 2023 21:12:27 -0500 Subject: [PATCH] v2 logging --- Segment/Troubleshooting/ZN_Troubleshooter_v01.ps1 | 4 +++- Segment/Troubleshooting/ZN_Troubleshooter_v02.ps1 | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Segment/Troubleshooting/ZN_Troubleshooter_v01.ps1 b/Segment/Troubleshooting/ZN_Troubleshooter_v01.ps1 index 3c92b91..67bd016 100644 --- a/Segment/Troubleshooting/ZN_Troubleshooter_v01.ps1 +++ b/Segment/Troubleshooting/ZN_Troubleshooter_v01.ps1 @@ -41,7 +41,9 @@ #> ## Run as admin if not as admin -if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit } +if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { + Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit +} function Write-Coord { param( diff --git a/Segment/Troubleshooting/ZN_Troubleshooter_v02.ps1 b/Segment/Troubleshooting/ZN_Troubleshooter_v02.ps1 index a47170f..751b9c2 100644 --- a/Segment/Troubleshooting/ZN_Troubleshooter_v02.ps1 +++ b/Segment/Troubleshooting/ZN_Troubleshooter_v02.ps1 @@ -45,12 +45,22 @@ if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti { # If not running as admin, write an error message and exit Write-Error "This script requires administrative privileges. Please run it as an administrator." - exit + Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit + #exit } # Define the path for the log file $logFilePath = "C:\temp\zeronetworksts.txt" +# Get the directory path from the file path +$folderPath = Split-Path -Path $logFilePath + +# Check if the folder exists +if (-not (Test-Path -Path $folderPath)) { + # The folder does not exist, so create it + New-Item -ItemType Directory -Path $folderPath +} + function Check-ServiceStatus { param ( [string]$ServiceName,