Install Chocolatey Remotely on Domain Computers
-
Enable PS Remoting in your Domain by following the Guide here
https://devblogs.microsoft.com/scripting/enable-powershell-remoting-to-enable-running-command
Then run this Powershell Script from a System with the Active Directory Powershell Modules installed: (Example below only installs it on the computers that are less or equal than 2 months old)
Import-Module ActiveDirectory # get today's date $today = Get-Date #Get today - 60 days (2 month old) $cutoffdate = $today.AddDays(-60) $computers= Get-ADComputer -Properties * -Filter {LastLogonDate -gt $cutoffdate} | Select-Object -ExpandProperty Name foreach ($comp in $computers) { Invoke-Command -computername $comp {Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))} }
Script is below
https://github.com/dbeato/scripts/blob/master/Chocolatey/Install-Chocolatey-AD.ps1This can be automated and changed as well to fit your needs.
-
This is some awesome stuff.
-
Nice! I was thinking about doing this soon.