Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Log-Message {
- param (
- [string]$message
- )
- $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
- $logMessage = "$timestamp - $message"
- Add-Content -Path $logFilePath -Value $logMessage
- }
- # Define the log file path
- $logFilePath = "C:\COMFiles\logs\CiscoVPNLog.txt"
- # Check if the log path exists, if not, create it
- if (-not (Test-Path -Path $logFilePath)) {
- # Create the log path
- New-Item -Path $logFilePath -Force
- Log-Message "###### Log path $logFilePath did not exist. Created it. This is the start of a new log ######"
- } else {
- Log-Message "###### Log path $logFilePath already exists. This is the start of a new log ######"
- }
- ##### Log creation end
- $profilePath = "C:\ProgramData\Cisco\Cisco Secure Client\VPN\Profile"
- # Check if the Profile path exists, if not, create it
- if (-not (Test-Path -Path $profilePath)) {
- # Create the Profile path
- New-Item -Path $profilePath -Force
- Log-Message "Profile path $profilePath did not exist. Created it."
- } else {
- Log-Message "Profile path $profilePath already exists."
- }
- Log-Message "Attempting to Deploy COMProfile.xml to the 'Profile' Directory"
- try {
- Copy-Item ".\COMProfile.xml" -Destination $profilePath -Force
- Log-Message "Deployment succeeded."
- } catch {
- Log-Message "Deployment Failed; Reason unknown"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement