Skip to content

Instantly share code, notes, and snippets.

@christaylorcodes
Created March 27, 2020 05:39
Show Gist options
  • Select an option

  • Save christaylorcodes/45ca9874ad0812f9fac4534d5fd6ebdc to your computer and use it in GitHub Desktop.

Select an option

Save christaylorcodes/45ca9874ad0812f9fac4534d5fd6ebdc to your computer and use it in GitHub Desktop.
Sudo code as an example of creating agents for each computer and remotely installing.
Import-Module VeeamPN
$Computers = Get-ADComputer -Filter * -Properties *
$Workstations = $Computers | Where-Object {$_.LastLogonDate -gt (Get-Date).AddDays(-30) -and $_.OperatingSystem -notlike "*server*"}
Connect-VeeamPN @ConnectionInfo
foreach($Computer in $Workstations){
$Result = New-VeeamPNClient -ClientName $Computer.Name
$ConfigPath = Get-VeeamPNClientConfig -ID $Result.id -OutputPath $ConfigDirectory
Update-VeeamPNConfig -Config $ConfigPath -Routes $Routes -DNS $DNS
$ScriptBlock = {
Install-Module VeeamPN
Import-Module VeeamPN
Invoke-RestMethod "$using:URL/$($using:Computer.Name).ovpn" -OutFile $using:ConfigPath
Install-OpenVPN -ConfigPath $using:ConfigPath
}
Invoke-Command -ComputerName $Computer.Name -ScriptBlock $ScriptBlock
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment