Created
May 11, 2023 18:56
-
-
Save Rvolvr/0edfb04f52a48e484a3ff39311889683 to your computer and use it in GitHub Desktop.
Distribute a PowerShell file to computers listed in a Tenable export CSV.
This file contains 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 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