Created
March 27, 2020 05:39
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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