Solved

OS version and printer issues

Posted on 2011-09-29
10
532 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:rstogsdill
  • 5
  • 4
10 Comments
 
LVL 13

Expert Comment

by:Govvy
ID: 36816528
In powershell:

PS > $ostype=Get-WMIObject win32_operatingsystem
PS > $ostype.OSArchitecture
64-bit
0
 

Author Comment

by:rstogsdill
ID: 36816560
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.)
0
 
LVL 6

Expert Comment

by:netjgrnaut
ID: 36816613
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.
0
 

Author Comment

by:rstogsdill
ID: 36816647
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.
0
 
LVL 6

Expert Comment

by:netjgrnaut
ID: 36816789
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!
0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 

Author Comment

by:rstogsdill
ID: 36816853
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.
0
 
LVL 6

Expert Comment

by:netjgrnaut
ID: 36817239
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".
0
 
LVL 6

Accepted Solution

by:
netjgrnaut earned 500 total points
ID: 36817793
Hmm.  I see that first link I posted doesn't have a good copy of the actual script.

Here it is:
http://gallery.technet.microsoft.com/scriptcenter/b7f74333-e78b-49d8-b23a-f1307d5b1ee6

What you're trying to do should be as simple as this...


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

Open in new window


...where:

\\SERVER\Share\printerList.txt is a file with one printer name per line (not including print server, based on your statement that both print servers have the same printer names shared).  You could change this line to point to a local file instead, but a centrally-maintained file would be best, IMO.

\\PSRV32\ is the name of your 32-bit print server.

\\PSRV64\ is the name of your 64-bit print server.

So... replace the placeholders with your actual server names, build and deploy the print share/printer name file on a server everyone can talk to, and you should be good to go.

I don't have a good test environment for this where I'm sitting, so if you run into specific errors, let me know!
0
 
LVL 6

Expert Comment

by:netjgrnaut
ID: 36817812
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...
0
 

Author Closing Comment

by:rstogsdill
ID: 36818887
Worked fine for me.
0

Featured Post

Are end users causing IT problems again?

You’ve taken the time to design and update all your end user’s email signatures, only to find out they’re messing up the HTML, changing the font and ruining the imagery. What can you do to prevent this? Find out how you can save your signatures from end users today.

Join & Write a Comment

Normally after a failure of Domain Controller, when promoting new DC the DC is renamed, we will discuss the options in Dcpromo to re-create the DC with the same name. Scenario: You are a small IT shop with two Domain Controllers (Domain Contr…
If you migrate a Terminal Server licenses server inside the 2008 server family, you can takte advantage of the build-in migration tool. If you like to migrate an older 2003 Server (and the installed client CALs) to a 2008 R2 server for example, you …
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now