Hi,
I'm trying to determine the version or name of Operating System used by the View Client for using in a Powershell script. I know under the View variables / Volatile Environment that ViewClient_Type stores Windows, but I wish to get more detailed info, then just Windows. I was wondering if anyone had come across similar scenarios and may be able to provide some assistance or suggestions on ways to workaround this. The environment is running VMWare View 5.0.
I have tried using a Remote WMI query - which works fine for a admin user, but the majority of users are a non admin on the local client, and I am a bit reluctant to have to change the WMI security on each client to get this to work.
Any help would be great.
Thanks
Alan
Try this one..
# ============================================================================================== # # # NAME: ADCompOSinfo # # AUTHOR: Mohamed Garrana , # DATE : 3/25/2010 # # COMMENT: # This script connects to Active Directory OU or just the root of the domain and recursivly gets all the computer objects # for each AD computer object it gets the Opertating system Type , Version and Service pack using information of the AD object # ============================================================================================== function get-alladcomputers { Trap { Write-Host -ForegroundColor Red " <<< Error >>> could not connect to Active directory, please make sure that ADpath var is correctly SET !" Break } $ADpath = "LDAP://DC=mantrac,DC=win2k,DC=dom" $searcher = New-Object DirectoryServices.DirectorySearcher $RootSearch = New-Object directoryservices.directoryentry $ADpath $searcher.searchroot = $RootSearch $searcher.filter = "(objectClass=computer)" $allcomps = $searcher.findall() foreach ($comp in $allcomps) { get-adcomputerinfo } $objs = $allcomps | Measure-Object $objcount = $objs.Count Write-Host -BackgroundColor green -ForegroundColor blue " Script succesfully Completed on $objcount Active Directory computer objects" } function get-adcomputerinfo { BEGIN { } PROCESS { Write-Host $comp.Properties.name try { $name = $comp.Properties.name[0] $os= $comp.Properties.operatingsystem[0] $osver= $comp.Properties.operatingsystemversion[0] $ossp=$comp.Properties.operatingsystemservicepack[0] } Catch { Write-Host -ForegroundColor Red " <<< WHoops ... >>> $name : Error reading a required property from the AD computer object, this might be a cluster resource name or the property has a null value . execution will continue anyway ;)" continue } finally { $computer = New-Object psobject $Computer | Add-Member NoteProperty Name ($name) $computer | Add-Member NoteProperty OperatingSystem ($os) $Computer | Add-Member NoteProperty OSVersion ($osver) $computer | Add-Member Noteproperty OSServicePack ($ossp) Write-Output $computer } } END{} } #set your variables :- #setting the ADpath variable $ADpath = "LDAP://DC=microsoft,DC=com" # this will grap all the AD computer objects in the microsoft.com domain #$ADpath = "LDAP://OU=Marketing,DC=Microsoft,DC=dom" #this will grap all the AD computer objects in the marketing OU in the microsoft domain #you can use the script like this to export the output into a csv file with all the computers and their OS information $outfile = "c:\test\ADcomps2.csv" #sets the location of the out csv file if you'r going to use Export-csv get-alladcomputers | Export-Csv $outfile #you can use the script like this to see a nice grid view of all the computers and their OS information get-alladcomputers | Out-GridView
Cheers, Udin
Try this one..
# ============================================================================================== # # # NAME: ADCompOSinfo # # AUTHOR: Mohamed Garrana , # DATE : 3/25/2010 # # COMMENT: # This script connects to Active Directory OU or just the root of the domain and recursivly gets all the computer objects # for each AD computer object it gets the Opertating system Type , Version and Service pack using information of the AD object # ============================================================================================== function get-alladcomputers { Trap { Write-Host -ForegroundColor Red " <<< Error >>> could not connect to Active directory, please make sure that ADpath var is correctly SET !" Break } $ADpath = "LDAP://DC=mantrac,DC=win2k,DC=dom" $searcher = New-Object DirectoryServices.DirectorySearcher $RootSearch = New-Object directoryservices.directoryentry $ADpath $searcher.searchroot = $RootSearch $searcher.filter = "(objectClass=computer)" $allcomps = $searcher.findall() foreach ($comp in $allcomps) { get-adcomputerinfo } $objs = $allcomps | Measure-Object $objcount = $objs.Count Write-Host -BackgroundColor green -ForegroundColor blue " Script succesfully Completed on $objcount Active Directory computer objects" } function get-adcomputerinfo { BEGIN { } PROCESS { Write-Host $comp.Properties.name try { $name = $comp.Properties.name[0] $os= $comp.Properties.operatingsystem[0] $osver= $comp.Properties.operatingsystemversion[0] $ossp=$comp.Properties.operatingsystemservicepack[0] } Catch { Write-Host -ForegroundColor Red " <<< WHoops ... >>> $name : Error reading a required property from the AD computer object, this might be a cluster resource name or the property has a null value . execution will continue anyway ;)" continue } finally { $computer = New-Object psobject $Computer | Add-Member NoteProperty Name ($name) $computer | Add-Member NoteProperty OperatingSystem ($os) $Computer | Add-Member NoteProperty OSVersion ($osver) $computer | Add-Member Noteproperty OSServicePack ($ossp) Write-Output $computer } } END{} } #set your variables :- #setting the ADpath variable $ADpath = "LDAP://DC=microsoft,DC=com" # this will grap all the AD computer objects in the microsoft.com domain #$ADpath = "LDAP://OU=Marketing,DC=Microsoft,DC=dom" #this will grap all the AD computer objects in the marketing OU in the microsoft domain #you can use the script like this to export the output into a csv file with all the computers and their OS information $outfile = "c:\test\ADcomps2.csv" #sets the location of the out csv file if you'r going to use Export-csv get-alladcomputers | Export-Csv $outfile #you can use the script like this to see a nice grid view of all the computers and their OS information get-alladcomputers | Out-GridView
Cheers, Udin
Thanks Milton for the AD Suggestion.
In the end, that was the path that I headed down. I do see flaws in using AD method, but I can live with those, seeing as we are checking the IP Ranges in the script as well.