Skip to content

Instantly share code, notes, and snippets.

@steviecoaster
Last active June 1, 2018 20:24
Show Gist options
  • Save steviecoaster/33a47184b56ec8bbff7c348e99c36301 to your computer and use it in GitHub Desktop.
Save steviecoaster/33a47184b56ec8bbff7c348e99c36301 to your computer and use it in GitHub Desktop.
Query for file
$Computers = Get-ADComputer -Filter * | Select Name
$file = /path/to/file
Foreach($c in $computers) {
#Uncomment to use UNC
If((Test-Path "\\$($c.Name)\C$\$file")){
#uncomment to use remoting
#If(Invoke-Command -Computer $c.Name -Command { (Test-Path $args[0])} -ArgumentList $file){
[pscustomobject]$cDetail = [ordered]@{
Name = $c.Name
IP = Resolve-DNSName $c.Name | Select-Object -ExpandProperty IPAddress
}
}
$cDetail | Format-Table -AutoSize
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment