notarat
2[H]4U
- Joined
- Mar 28, 2010
- Messages
- 2,501
So...I need to pull a listing of all active computers in my OU and retrieve the screensize of the connected monitor (or monitors)
For you guys who are admins, this isn't difficult. For me, it's simply not "do-able" because I'm not allowed permission to run the script against the computers in my OU. I have to, instead, create the script and then forward it to someone who has appropriate permissions. They simply copy/paste my script like a damn monkey and click "Run".
Because of this insane restriction, I thought I would paste the script here in hopes that someone can give it a look over and maybe run it to let me know if it is properly pulling the information I need.
When I run a slightly modified script (pointed only at my local machine) I get the data in the following format (which is how I want the info displayed)
COMPUTERNAME,24 20
Is it pulling the same info for you, in the same format?
For you guys who are admins, this isn't difficult. For me, it's simply not "do-able" because I'm not allowed permission to run the script against the computers in my OU. I have to, instead, create the script and then forward it to someone who has appropriate permissions. They simply copy/paste my script like a damn monkey and click "Run".
Because of this insane restriction, I thought I would paste the script here in hopes that someone can give it a look over and maybe run it to let me know if it is properly pulling the information I need.
Code:
Import-Module ActiveDirectory
$computers = (Get-ADComputer -Filter {Enabled -eq 'True'} -searchbase INSERTYOUROUHERE'-searchscope subtree -Properties Name | select-object -expandproperty name)
Write-host $computers
foreach ($Computer in $computers) {
write-host $computers
$output = [PSCustomObject]@{ComputerName = $Computer;MonitorSizes=''}
$oWmi = Get-WmiObject -Namespace 'root\wmi' -ComputerName $Computer -Query "SELECT MaxHorizontalImageSize,MaxVerticalImageSize FROM WmiMonitorBasicDisplayParams";
$sizes = @();
if ($oWmi.Count -gt 1) {
foreach ($i in $oWmi) {
$x = [System.Math]::Pow($i.MaxHorizontalImageSize/2.54,2)
$y = [System.Math]::Pow($i.MaxVerticalImageSize/2.54,2)
$sizes += [System.Math]::Round([System.Math]::Sqrt($x + $y),0)
}##endforeach
} else {
$x = [System.Math]::Pow($oWmi.MaxHorizontalImageSize/2.54,2)
$y = [System.Math]::Pow($oWmi.MaxVerticalImageSize/2.54,2)
$sizes += [System.Math]::Round([System.Math]::Sqrt($x + $y),0)
}##endif
$output.MonitorSizes = $sizes
$Msz = ([string] $output.MonitorSizes )
$strDone = "$computer,$Msz"
Add-Content c:\outputfiles\MonitorSizes.txt -value $strdone
}
When I run a slightly modified script (pointed only at my local machine) I get the data in the following format (which is how I want the info displayed)
COMPUTERNAME,24 20
Is it pulling the same info for you, in the same format?