Blog
By Tommy Gunn on 5/31/2009 8:24:20 PM • Rank (5514) • Views 6049
0

0

I have been working with Powershell for some time now, and thought it would be nice to start using Powershell with SCCM 2007 to retrieve data collected via client agents. Not many examples out there, so I thought I would provide some.

I started with my knowledge of Powershell and WMI, and using  this discussion on TechNet Social Forums, I expanded into a simple parameterized script to retrieve basic inventory data.  This will return basic inventory data about the client systems: 

Name, IPAddresses, AD Org Unit, Client Version, OS Version

Instructions for  Use: Cut-and-paste the following script into Notepad and save with a .ps1 extension. If you run the script with no parameters, it will echo syntax to your Powershell window. Watch line wrap when you do the cut-and-paste.

#------------Begin Sample Script--------------

param($SiteSvr,$SiteCode)

 

#Echo syntax if script is run with no parameters

     if ($SiteSvr -eq $null) {

        Write-Host ""

        Write-Host "SYNTAX:";

        Write-Host "This script has 2 required parameters.";

        Write-Host ""

        Write-Host "-SiteSvr: Name of ConfigMgr 2007 Site Server";

        Write-Host "Ex: sccmsvr.fqdn.local";

        Write-Host ""

        Write-Host "-SiteCode: Three character SCCM Site Code";

        Write-Host "Ex: ‘NYC";

        Write-Host ""

 exit;

     }

$query = New-Object System.Management.ObjectQuery

$query.QueryString = "Select * from SMS_R_System"

$s = New-Object System.Management.ManagementObjectSearcher($query)

$s.Scope.Path = "\\" + $SiteSvr + "\root\sms\site_" + "$SiteCode"

$s.Get() | Select NetbiosName, SystemGroupName, IPAddresses, ClientVersion, OperatingSystemNameandVersion

#------------End Sample Script--------------

This is all for now. In the next post on this topic, I will dig further into the possibilities of Powershell with SCCM 2007.

 

Map Location


GPS Latitude: 0.00000 Longitude: 0.00000
Comments - Comment RSS


Who Viewed
Who Reviewed
Categories
Related Pages
Shortened URL
http://tinyurl.com/yk2wb99

Top Contributors
Featured Members
Pete Zerger
Points: 65622
Level: System Center Expert
Tommy Gunn
Points: 42748
Level: System Center Expert
Simon Skinner
Points: 40804
Level: System Center Expert
Stefan Koell
Points: 28999
Level: System Center Expert
Andreas Zuckerhut
Points: 27734
Level: System Center Expert