Advertisement
jgtechnology

Cisco Profile Deployment

Feb 20th, 2025
91
0
68 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 1.33 KB | Source Code | 0 0
  1. function Log-Message {
  2.     param (
  3.         [string]$message
  4.     )
  5.     $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
  6.     $logMessage = "$timestamp - $message"
  7.     Add-Content -Path $logFilePath -Value $logMessage
  8. }
  9.  
  10. # Define the log file path
  11. $logFilePath = "C:\COMFiles\logs\CiscoVPNLog.txt"
  12.  
  13. # Check if the log path exists, if not, create it
  14.     if (-not (Test-Path -Path $logFilePath)) {     
  15.         # Create the log path
  16.         New-Item -Path $logFilePath -Force
  17.         Log-Message "###### Log path $logFilePath did not exist. Created it. This is the start of a new log ######"
  18.     } else {
  19.         Log-Message "###### Log path $logFilePath already exists. This is the start of a new log ######"
  20.     }
  21.  
  22. ##### Log creation end
  23.  
  24. $profilePath = "C:\ProgramData\Cisco\Cisco Secure Client\VPN\Profile"
  25.    
  26. # Check if the Profile path exists, if not, create it
  27. if (-not (Test-Path -Path $profilePath)) {     
  28.     # Create the Profile path
  29.     New-Item -Path $profilePath -Force
  30.     Log-Message "Profile path $profilePath did not exist. Created it."
  31. } else {
  32.     Log-Message "Profile path $profilePath already exists."
  33. }
  34.  
  35. Log-Message "Attempting to Deploy COMProfile.xml to the 'Profile' Directory"
  36.  
  37. try {  
  38.     Copy-Item ".\COMProfile.xml" -Destination $profilePath -Force
  39.    
  40.     Log-Message "Deployment succeeded."
  41. } catch {
  42.     Log-Message "Deployment Failed; Reason unknown"
  43. }
  44.  
Tags: intune
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement