• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 552
  • Last Modified:

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.
0
rstogsdill
Asked:
rstogsdill
  • 5
  • 4
1 Solution
 
GovvyCommented:
In powershell:

PS > $ostype=Get-WMIObject win32_operatingsystem
PS > $ostype.OSArchitecture
64-bit
0
 
rstogsdillAuthor Commented:
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
 
netjgrnautCommented:
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
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell┬« is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
rstogsdillAuthor Commented:
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
 
netjgrnautCommented:
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
 
rstogsdillAuthor Commented:
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
 
netjgrnautCommented:
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
 
netjgrnautCommented:
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
 
netjgrnautCommented:
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
 
rstogsdillAuthor Commented:
Worked fine for me.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now