Skip to content

Instantly share code, notes, and snippets.

@Rvolvr
Created May 11, 2023 18:56
Show Gist options
  • Save Rvolvr/0edfb04f52a48e484a3ff39311889683 to your computer and use it in GitHub Desktop.
Save Rvolvr/0edfb04f52a48e484a3ff39311889683 to your computer and use it in GitHub Desktop.
Distribute a PowerShell file to computers listed in a Tenable export CSV.
# Import the list
$list = Import-csv -path 'C:\Users\ADMIN\Downloads\file.csv'
# Define the script block: call PowerShell to allow the script.
$script = {powershell /executionpolicy bypass 'c:\temp\script.ps1'}
Foreach ($Comp in $list."asset.Name") {
# Test to see if machine is online before doing the work.
If (Test-Path \\$comp\c$\temp){
Robocopy.exe C:\files\ \\$comp\c$\temp\ /MT /NP
Invoke-Command -ComputerName $Comp -ScriptBlock $script -Verbose -AsJob
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment