?
Solved

OS version and printer issues

Posted on 2011-09-29
10
Medium Priority
?
543 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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
 

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 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

OfficeMate Freezes on login or does not load after login credentials are input.
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Suggested Courses

764 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