Link to home
Start Free TrialLog in
Avatar of rstogsdill
rstogsdill

asked on

OS version and printer issues

I am looking for a way to detect the os of a system 32bit or 64bit. If it detect 64bit it should error out and close. If not it should either remove the mapped printers or point the os to the new printer mapping.
Avatar of Govvy
Govvy
Flag of United States of America image

In powershell:

PS > $ostype=Get-WMIObject win32_operatingsystem
PS > $ostype.OSArchitecture
64-bit
Avatar of rstogsdill
rstogsdill

ASKER

Thanks for the reply.. (if you haven noticed, im not much on scripting) Anyway.. Where would i go from here. What i want to do is check the os version, then if it is 32bit point the 32bit os's to a 32bit print server. We have a 32 and 64 bit print servers running and hosting the same printers. (no i did not come up with that plan.)
Dumb question, but why not load both 32 and 64 bit drivers with each print server/share?  I assume you're running two different shares - one for 32bit and one for 64bit.  Windows server supports better than that - multi OS version/architecture driver packages.  A much better solution than a script that "errors out" as a method of problem solving.

Just my $0.02.  Lobby for a better print server implementation, rather than put a band-aid on what you've got.
I agree.. but im not the man in charge. So this is the way i have to get it done. I wish we would move every one to the 64bit server, but it gave him some issues with the 32bit drivers. So now we have a  64bit print server and a 32bit print server. I know its bad mojo and all that.. but he is happy with it.
High-level overview...

Use the snippet provided above to determine the system architecture.

Use this page to see methods for scripting printer connections with PowerShell.

Write a script that does the system architecture detection first, then runs one set of printer connections or the other.

Voila - you've got a single script that can be executed at logon by any user (with sufficient rights to add printers to the client) from any client (32- or 64-bit) to connect to the appropriate set of printers.

That should be enough to get you rolling.  PowerShell is easy.  You'll be much more "on scripting" when you're done.

IMHO, you shouldn't just grab scripts off a site like this and run them if you don't know what they do.  That being said, if you put together something rudimentary from the info and links provided, and you run into specific problems, I'd be happy to look at your script and troubleshoot specific errors.

Good luck!
Thanks for the tips. I really wish i wasnt locked into doing things like this.. But im just a contractor. I really have no say in the build. I did point out the issues with running 2 printservers when one would do.

Let me work on it and i will accept as a solution.
That's the spirit! Feel free to return to this thread w/scriptlets if you want additional input. It's an interesting problem to solve, and if time permits on my current gig (just a contractor myself), I'll look more closely at the code link I sent you for a solution.

The to-do is to remove the interactivity in the solution provided under my second link, then fork into it with an "if this architecture, do that" - "elseif this architecture do theother".
ASKER CERTIFIED SOLUTION
Avatar of netjgrnaut
netjgrnaut
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hmmm.  You may need to change the $printClass line based on architecture too.

$ostype = Get-WMIObject win32_operatingsystem
$printerNames = gc "\\SERVER\Share\printerList.txt"
if ($ostype.OSArchitecture -eq "32-bit") { 
    $printClass = [wmiclass]"win32_printer"
    $printServer = "\\PSRV32\" 
}
elseif ($ostype.OSArchitecture -eq "64-bit") { 
    $printClass = [wmiclass]"win64_printer"
    $printServer = "\\PSRV64\" 
}
foreach ($printer in $printerNames) {
    $printerPath = $printServer + $printer
    $printClass.AddPrinterConnection($printerPath)
}

Open in new window


Not sure.  I'd try it the first way first, but just in case...
Worked fine for me.