Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Trying to modify a script to use test-connections in multiple domains?

$
0
0

Hey Scripting Guy!

I've created the script (below) to use test-connection against a list of hosts and write the results of the machines that respond to a .txt file. The only issue is that one of my sites utilizes two separate domains, does anyone have any advice as far aswhen a test connection fails, retrying the command using another domain name? (server.domain.com)

I'll take any advice at this point... Thanks!

New-PSDrive -Name S -PSProvider FileSystem -Root \\server\share -ErrorAction SilentlyContinue
Get-ChildItem "S:\Folder1\Folder2\backup\backup Audits\Host Audits" -Filter *.txt | `
Foreach-Object{
    $content = Get-Content $_.FullName
    #$SiteName = Get-ChildItem "S:\Folder1\Folder2\backup\backup Audits\Host Audits"

    #Find alive machines, and write their hostnames to output file for auditing
    Test-Connection -count 5 -ErrorAction SilentlyContinue $Content | Select-object -unique | Out-File      "S:\Folder1\Folder2\backup\backup Audits\Audit results by Site\$_"


}


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>