@echo off REM ============================================================================ REM Set-NetworkPrivate.bat REM Changes network profile from Public to Private for WinRM HTTPS REM ============================================================================ REM Setup logging set "LOG_DIR=S:\DT\ADATA\SCRIPT\DEPLOY\LOGS" set "HOSTNAME=%COMPUTERNAME%" set "TIMESTAMP=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%-%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%" set "TIMESTAMP=%TIMESTAMP: =0%" set "LOG_FILE=%LOG_DIR%\%HOSTNAME%-%TIMESTAMP%-NETWORK-PROFILE.txt" REM Create log directory if it doesn't exist if not exist "%LOG_DIR%" ( mkdir "%LOG_DIR%" 2>nul ) echo. echo ======================================== echo Set Network Profile to Private echo ======================================== echo. echo Hostname: %COMPUTERNAME% echo Log File: %LOG_FILE% echo. REM Check for administrator privileges net session >nul 2>&1 if %errorLevel% neq 0 ( echo [ERROR] This script requires Administrator privileges. echo Please right-click and select "Run as Administrator" echo. pause exit /b 1 ) echo [OK] Running with Administrator privileges echo. REM Get the directory where this batch file is located set "SCRIPT_DIR=%~dp0" echo Script directory: %SCRIPT_DIR% echo. REM Check if PowerShell script exists if not exist "%SCRIPT_DIR%Set-NetworkPrivate.ps1" ( echo [ERROR] Set-NetworkPrivate.ps1 not found in script directory echo Please ensure all files are in the same directory echo. pause exit /b 1 ) echo [OK] Required files found echo. REM Execute PowerShell script echo Changing network profile to Private... echo. PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command ^ "& '%SCRIPT_DIR%Set-NetworkPrivate.ps1'" > "%LOG_FILE%" 2>&1 if %errorLevel% neq 0 ( echo. echo [ERROR] Failed with error code: %errorLevel% echo. echo Log saved to: %LOG_FILE% pause exit /b %errorLevel% ) echo. echo ======================================== echo [SUCCESS] Network Profile Updated echo ======================================== echo Log saved to: %LOG_FILE% echo. pause