Solved

OS version and printer issues

Posted on 2011-09-29
10
535 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
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:…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

773 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