Created
November 27, 2017 17:24
-
-
Save danjpadgett/b5c3cb1b73cd629dbb4766d59c8a4265 to your computer and use it in GitHub Desktop.
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
$result = @() | |
$time = 1 | |
$list = Get-Content .\list.txt | |
Foreach ($i in $list) | |
{ | |
$intSize = $intSize + $objFile.Length | |
$resData = New-Object System.Object | |
$resData | Add-Member -type NoteProperty -name ComputerName -value $i | |
if (Test-Connection -ComputerName $i -Quiet -Count 1) | |
{ | |
try { | |
$resData | Add-Member -type NoteProperty -name SiteCode -value ((Invoke-WMIMethod -ComputerName $i –Namespace root\ccm –Class SMS_Client –Name GetAssignedSite -ErrorAction Stop).sSiteCode) } | |
catch {$resData | Add-Member -type NoteProperty -name SiteCode -value ("Connection Failed : $($error[0].Exception.Message)") -Force} | |
} | |
else {$resData | Add-Member -type NoteProperty -name SiteCode -value ('Connection Failed : Ping Failed')} | |
$result += $resData | |
Write-Progress -activity "Checking Site Codes for $($list.length) clients" -status "Percent checked: " -PercentComplete (($time / $list.length) * 100) | |
$time++ | |
} | |
$result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment