/build/static/layout/Breadcrumb_cap_w.png

PowerShell script needs to reference a TxT file or AD for a list of computer names.

The script below is the only script I could find to give me the actual printer driver version and not just the OS comparability number ( 0,1,2,3 ). Unfortunately I am new to PowerShell and can't seem to get this script to reference a txt file or AD for a list of computer names, I also need it to list the computer name next to the results.. Any help on this would be great. Thank you in advance.

The systems I will be running this script on will be Win7 and possibly Server 2008

I have Tried the Get-content and AD module on this script, the same way I use them on all of my other scripts but for some reason they just will not work with this one. any help or direction that will point to why typical methods are not working would be fantastic. 

Param (
	[string]$PrintServer = "yourprintserver"
)
$Results = @()

ForEach ($Driver in (Get-WmiObject Win32_PrinterDriver -ComputerName $PrintServer))
{	$Drive = $Driver.DriverPath.Substring(0,1)
	$Results += New-Object PSObject -Property @{
		Name = $Driver.Name
		Version = (Get-ItemProperty ($Driver.DriverPath.Replace("$Drive`:","\\$PrintServer\$Drive`$"))).VersionInfo.ProductVersion
	}
}
$Results

0 Comments   [ + ] Show comments

Answers (2)

Posted by: anonymous_9363 9 years ago
Red Belt
0
In any language, finding a script that does *exactly* what you want will be a major Red Letter Day. You will almost certainly need to combine one or more examples. This, apart from anything else, is a great way to learn a language.

To get you started, why not Google 'powershell active directory list all computers'? The first hit is a nice TechNet article which contains a script to create a CSV on all the machines in a domain.

Comments:
  • I have tried several combinations of Get-content and importing the AD modules which work on ALL of my other scripts however I just can't figure out why the typical ways to reference a TXT file or AD will not work with this script. I am not new to scripting just scripting in powershell. but thank you for the suggestion of googling it. - rbtmtz 9 years ago
Posted by: Thegunner 9 years ago
Second Degree Green Belt
0
Here is something that will help you to get started
#First one,pulls a list of computers from a text file in to a variable, then the 2nd line reads through the computers and put in to another variable to work with, you can just use $comp, but I like to keep the original variable
    $Comp = GC 'Path to text file of computer names'
    $ComputerList = $Comp | Foreach $_ {Write-Host $_}

#Pulls a AD user by using the filter property to find a specific user, then it list the user AD attributes, last lien exports to a csv
    $ADUser = Get-ADUser -filter {SamAccountName -like 'testuser'}
    $ADUser #List User information
    $ADUser | Export-CSV 'path\UserInfo.csv' #Export info to CSV

With this info you should be able to pull something together that you need.

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ